我試圖在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。當用戶點擊確定按鈕時,它將被調用。 –