Tôi tạo ra một tờ hành động, nhưng vấn đề là phương pháp đại biểu không được gọiUIActionSheet với nhanh chóng
myActionSheet = UIActionSheet()
myActionSheet.addButtonWithTitle("Add event")
myActionSheet.addButtonWithTitle("close")
myActionSheet.cancelButtonIndex = 1
myActionSheet.showInView(self.view)
/// UIActionSheetDelegate
func actionSheet(myActionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){
if(myActionSheet.tag == 1){
if (buttonIndex == 0){
println("the index is 0")
}
}
}
tôi đã sử dụng một cách khác mà làm việc tốt với iOS 8 nhưng không hoạt động với iOS 7:
var ActionSheet = UIAlertController(title: "Add View", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet)
ActionSheet.addAction(UIAlertAction(title: "Add event", style: UIAlertActionStyle.Default, handler:nil))
self.presentViewController(ActionSheet, animated: true, completion: nil)
Bất kỳ ý tưởng nào để khắc phục sự cố?
tờ hành động và xem cảnh báo được khấu hao trong iOS 8 và alertController được giới thiệu. – nikhil84
Vâng nó không được chấp nhận nhưng nếu bạn hỗ trợ ứng dụng của bạn cho iOS 7 thì alertController sẽ không hoạt động. Vì vậy, hãy kiểm tra phiên bản iOS tốt hơn và gọi mã thích hợp cho iOS 8 và iOS 7 –
Hãy xem câu trả lời này - http://stackoverflow.com/questions/27787777/how-to-create-uiactionsheet-actions/27798750#27798750 – Kampai