Tôi đang sử dụng ActionSheet trong ứng dụng của mình. Trên iPhone của tôi nó hoạt động, nhưng nó không trên giả lập iPad.ActionSheet không hoạt động iPad
đây là mã của tôi:
@IBAction func dialog(sender: AnyObject) {
let optionMenu = UIAlertController(title: nil, message: "Choose Option", preferredStyle: .ActionSheet)
let deleteAction = UIAlertAction(title: "Delete", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
println("Filtre Deleted")
})
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
(alert: UIAlertAction!) -> Void in
println("Cancelled")
})
optionMenu.addAction(deleteAction)
optionMenu.addAction(cancelAction)
self.presentViewController(optionMenu, animated: true, completion: nil)
}
Và lỗi của tôi:
Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
[Link] này (http://stackoverflow.com/questions/24224916/presenting-a-uialertcontroller-properly-on-an-ipad-using-ios-8) có thể giúp bạn. –
ios 8 và ở trên không có hành động bảng UIActionController dụ u cần phải đặt loại như UIAlertControllerStyleActionSheet .... điều này có thể giúp bạn .... mặc dù uipopover được đề xuất cho iPad .... – Spynet
Bạn phải trình bày nó như là một popover trên iPad – Totka