繁体   English   中英

Swift-TVOS取消UIAlertController

[英]Swift-tvOS dismissing UIAlertController

我正在为tvOS做应用,我在取消UIAlertController问题。 我在普通的UIViewController上展示一个UIAlertController 当我按下电视遥控器上的“菜单”按钮以消除警报时,父视图控制器首先被解除,而当我第二次按下菜单按钮时, 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)
    }

我怎样才能只关闭alertcontroller 谢谢。

要关闭警报控制器,只需调用此行代码即可。

allertController.dismissViewControllerAnimated(true, completion: nil)

或者,您可以添加警报措施。

let alertAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)
allertController.addAction(alertAction)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM