UIAlewrtController按下导航控制器中的按钮(见图)
执行顺序:
-
on push警报控制器被激活
-
选择"Take an Action"或"Request an Action"视图控制器ActionDetialsVC被激活 .
-
关于显示ActionDetialsVC
-
on ActionDetialsVC已关闭
-
iitial controlers后箭头移动了
将断点放在:
-
self.present(alert,animated:true,completion:nil)
-
2个警报处理程序中的第一个Swift指令
这些断点之间可以看到奇怪的导航后退按钮行为 .
仅在我的视图中引入警报控制器时才会出现此问题!
谢谢您的帮助
问题形象:
代码:
func addPressed(_ sender: Any) {
let alert = UIAlertController (title: "Add an Action", message: nil, preferredStyle: UIAlertControllerStyle.alert)
let request = UIAlertAction (title: actionType.Request.Str(), style: UIAlertActionStyle.default, handler: {
action in
self.actionTypeTemp = actionType.Request.Str()
self.performSegue(withIdentifier: "segueActionDetailsVC", sender: nil)
} )
let take = UIAlertAction (title: actionType.Take.Str(), style: UIAlertActionStyle.default, handler: {
action in
self.actionTypeTemp = actionType.Take.Str()
self.performSegue(withIdentifier: "segueActionDetailsVC", sender: nil)
} )
let done = UIAlertAction (title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil )
alert.addAction(request)
alert.addAction(take)
alert.addAction(done)
self.present (alert, animated: true, completion: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "segueActionDetailsVC" {
if let destination = segue.destination as? ActionDetailsVC {
if let action = sender as? PActions {
destination.actionToEdit = action
}
else {
if actionTypeTemp == actionType.Request.Str() {
destination.relatedContact = self.contact
destination.title = actionType.Request.Str()
}
else {
destination.relatedContact = self.contact
destination.title = actionType.Take.Str()
}
}
}
}
}