美文网首页iOS
alert的用法(Swift)

alert的用法(Swift)

作者: YBDSup | 来源:发表于2017-07-09 01:48 被阅读0次
    @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)

        本文链接:https://www.haomeiwen.com/subject/hwfshxtx.html