我以前遇到過類似的問題,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