Iphone 如何在Swift中使用警报视图展开segue?
我有几个视图控制器。如果警报视图得到确认,我需要返回到第一个视图控制器。这就是我在没有放松阶段的情况下的做法:Iphone 如何在Swift中使用警报视图展开segue?,iphone,swift,uialertview,unwind-segue,Iphone,Swift,Uialertview,Unwind Segue,我有几个视图控制器。如果警报视图得到确认,我需要返回到第一个视图控制器。这就是我在没有放松阶段的情况下的做法: @IBAction func unwindToDelete ( segue: UIStoryboardSegue ) { let alertView = UIAlertController(title: "Delete?", message: "Are you sure you wante to delete?", preferredStyle: .ActionSheet)
@IBAction func unwindToDelete ( segue: UIStoryboardSegue ) {
let alertView = UIAlertController(title: "Delete?", message: "Are you sure you wante to delete?", preferredStyle: .ActionSheet)
let deleteAction = UIAlertAction (title: "Delete", style: .Destructive ) { alertAction in
self.deleteChoice = true
}
let cancelAction = UIAlertAction (title: "Cancel", style: .Cancel ) { alertAction in
}
alertView.addAction(deleteAction)
alertView.addAction(cancelAction)
self.presentViewController(alertView, animated: true, completion: nil)
}
但是如果我这样做,在这段代码中,它会因为最后一行代码而崩溃
这就是错误:
2015-04-30 14:59:45.605 PhotosCollection[4624:182995]
popToViewController:transition: called on <UINavigationController 0x7a67aeb0>
while an existing transition or presentation is occurring; the navigation
stack will not be updated.
2015-04-3014:59:45.605照片收集[4624:182995]
popToViewController:转换:已调用
当现有转换或呈现正在发生时;导航
堆栈将不会被更新。
如何在能够解开segue的同时完成警报视图
谢谢你你在放松发生后发出警报。如果用户选择取消删除,您希望能够完全不执行展开。我建议如下:
“doUnwind”
@IBAction
中,显示警告,询问用户是否确实要删除 @IBAction func deleteButton (button: UIButton) {
let alertView = UIAlertController(title: "Delete?", message: "Are you sure you wante to delete?", preferredStyle: .ActionSheet)
let deleteAction = UIAlertAction (title: "Delete", style: .Destructive ) { alertAction in
self.performSegueWithIdentifier("doUnwind", sender: self)
}
let cancelAction = UIAlertAction (title: "Cancel", style: .Cancel ) { alertAction in
}
alertView.addAction(deleteAction)
alertView.addAction(cancelAction)
self.presentViewController(alertView, animated: true, completion: nil)
}
看起来您在播放动画时正在调用unwind segue。。。在设置一定的延迟后尝试将其释放…您是否尝试在按钮上添加处理程序,以便在截获“删除”事件后再释放?