新手,用swift寫ios應用時,報了個錯誤
popToViewController:transition: called on <UINavigationController 0x7f901981a400> while an existing transition or presentation is occurring; the navigation stack will not be updated.
場景是,在一個頁面中點擊按鈕,彈出一個提示框UIAlertController
let dialog = UIAlertController(title: "提示", message: "請選擇TODO的類型", preferredStyle: UIAlertControllerStyle.alert);
let okAction = UIAlertAction(title: "好的", style: .default, handler:{(action) ->Void in
print("onOK");
});
let cancelAction = UIAlertAction(title: "取消", style: .cancel){(action) -> Void in
print("onCancel")
};
dialog.addAction(cancelAction);
dialog.addAction(okAction);
self.present(dialog, animated: true, completion: {
print("completion");
});
調用了ViewController的present方法進行彈窗,但是當點擊按鈕之後,窗口彈出後又自動消失了。
後來,發現是因爲,按鈕綁定了個close事件,close事件會觸發關閉當前頁。由於,UIAlertController是顯示在當前ViewController之上的,如果關閉了的話,相當於它沒有了載體。
記錄。