@IBAction func change(_ sender: Any) {
let deepAlert2 = UIAlertController(title: "不保存", message: "不保存刚刚的修改吗", preferredStyle: .alert)
let yesAction = UIAlertAction(title: "不保存", style: .default, handler: { (action:UIAlertAction) in
self.presentedViewController?.dismiss(animated: true, completion: nil)
self.navigationController?.popViewController(animated: true)
// 我这里是直接通过popViewController来进行返回上一层的操作的。因为用了这个changeBtn来覆盖掉原来NavigationController自带的那个返回按钮。
})
let noAction = UIAlertAction(title: "返回继续编辑", style: .default, handler: { (action:UIAlertAction) in
self.presentedViewController?.dismiss(animated: true, completion: nil)
// do nothing
})
deepAlert2.addAction(yesAction)
deepAlert2.addAction(noAction)
// self.presentedViewController?.dismiss(animated: true, completion: nil)
self.present(deepAlert2, animated: true, completion: nil)
}
网友评论