我试图在alertView后将popViewController导航到导航堆栈中的前一个视图控制器。截至目前,我的程序将无法运行popViewController方法,因为alertView是在路上,并提出了错误:转到导航堆栈中的前一个控制器(Swift)
UINavigationController 0x17670900 while an existing transition or presentation is occurring; the navigation stack will not be updated.
我该如何去对用户运行后popViewController方法点击从OK alertView?我是否必须设置一个代表,用于检测何时使用的点击确定?
这里是我的代码:
//alertView after Picture saved
let alertView = UIAlertController(title: "Success!", message: "Record Saved to Database", preferredStyle: .Alert)
alertView.addAction(UIAlertAction(title: "Ok", style: .Default, handler: nil))
self.presentViewController(alertView, animated: true, completion: nil)
//go to previous controller using popViewController, doesnt work, brings up error message
if let navController = self.navigationController {
navController.popViewControllerAnimated(true)
}
您正在同时调用两个转换:当前警报和弹出前一个视图控制器。 像现在这样调用当前警报,但在动作处理程序中调用popViewController。当用户点击确定按钮时,它将被调用。 –