[英]Swift-tvOS dismissing UIAlertController
I am doing app for tvOS
and I have problem with canceling UIAlertController
. 我正在为tvOS
做应用,我在取消UIAlertController
问题。 I am presenting a UIAlertController
on top of a normal UIViewController
. 我在普通的UIViewController
上展示一个UIAlertController
。 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. 当我按下电视遥控器上的“菜单”按钮以消除警报时,父视图控制器首先被解除,而当我第二次按下菜单按钮时, UIAlertController
正确消失,但是在父视图控制器之后,我不想关闭它。
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
? 我怎样才能只关闭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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.