I am doing app for tvOS
and I have problem with canceling UIAlertController
. I am presenting a UIAlertController
on top of a normal UIViewController
. When I push Menu button on tv remote to dismiss the alert, the parent view controller is dismissed first and when i press menu button for the second time, UIAlertController
disappeared correctly, but after the parent view controller, which i don't want to dismiss.
func showTextDescription(message:String?) {
let allertController=UIAlertController(title: title, message: message, preferredStyle: .ActionSheet)
// Cancel action (is invisible, but enables escape)
allertController.addAction(UIAlertAction(title: nil, style: .Cancel, handler: nil))
self.presentViewController(allertController, animated: true, completion: nil)
}
How can i dismiss only alertcontroller
? Thanks.
Just call this line of code when you want to dismiss the alert controller.
allertController.dismissViewControllerAnimated(true, completion: nil)
Or you can add an alert action.
let alertAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)
allertController.addAction(alertAction)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.