@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)
}
alert的用法(Swift)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 一.闭包的介绍 闭包是功能性自包含模块,可以在代码中被传递和使用。 Swift 中的闭包与 C 和 Objecti...
- 首先来说说什么是typealias typealias是用来为已经存在的类型重新定义名字的,通过命名,可以使代码变...
- 1.按钮的创建 (1)按钮有下面四种类型: UIButtonType.system:前面不带图标,默认文字颜色为蓝...
- 1、文本输入框的创建##### 其中,文本输入框的边框样式有以下几种:public enum UITextBord...