【发布时间】:2016-11-01 19:48:54
【问题描述】:
我过去在使用 UIAlertController 时也遇到过类似的问题,因为在 UIAlertController 被解除后 UI 线程上总是存在延迟。
我现在的问题是,如果用户单击“确定”UIAlertAction,我想执行一个转场,如果按下“取消”UIAlertAction,则什么也不会发生。
这是我的代码:
// create the uialertcontroller to display
let alert = UIAlertController(title: "Do you need help?",
message: "Would you like to look for a consultant?",
preferredStyle: .alert)
// add buttons
let okay = UIAlertAction(title: "Yes, please.", style: .default, handler: {_ in
self.performSegue(withIdentifier: "segue", sender: nil)
})
let no = UIAlertAction(title: "No, I'm okay.", style: .cancel, handler: nil)
alert.addAction(okay)
alert.addAction(no)
self.present(alert, animated: true, completion: nil)
当前发生的情况是,当我点击“确定”时,segue 正在执行,但我只能看到过渡的最后时刻(即动画在 UIAlertController 被解除时开始)。
一旦UIAlertController 被解除,我如何让segue 开始?
注意 - 如果有其他方法,我不喜欢用 hacky 方法解决这个问题,比如在固定延迟后执行 segue。
谢谢!
【问题讨论】:
-
@matt 所以真的没有办法做到这一点,除非我在
n秒后制作动画?另外 - 我没有在哪里说禁止
标签: swift segue uialertcontroller