我以前遇到过类似的问题,UIAlertController
,因为在UIAlertController
被解雇后,UI线程总会有滞后。
我现在的问题是,如果用户点击“Okay”UIAlertAction
,我想执行一个segue,如果按下“Cancel”UIAlertAction
,则不会发生任何事情。
这是我的代码:UIAlertController解除后执行segue
// 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,如果还有其他方法的话。
谢谢!
@马特所以不是一个真正的办法做到这一点,除非我'n'秒后动画?此外 - 没有我说的禁止 – uti0mnia