UIAlertController的进化

来源:互联网 发布:js引用 编辑:程序博客网 时间:2024/05/01 12:16

根据书上的代码敲时发现
uialertview已经不可用了(包括action sheet)
建议使用UIAlertController
这个东西是个好东西

@IBAction func nv(_ sender: Any) {        let alertController = UIAlertController(title: "系统提示",                                                message: "测试", preferredStyle: .alert)        let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: nil)       let okAction = UIAlertAction(title: "好的", style: .default, handler: {            action in//       })       alertController.addAction(cancelAction)       alertController.addAction(okAction)        self.present(alertController, animated: true, completion: nil)    }    @IBAction func vv(_ sender: Any) {        let alertController = UIAlertController(title:"保存或删除数据", message:"删除数据将不可恢复", preferredStyle: UIAlertControllerStyle.actionSheet)        let cancelAction = UIAlertAction(title:"取消", style: UIAlertActionStyle.cancel, handler: nil)        let deleteAction = UIAlertAction(title:"删除", style: UIAlertActionStyle.destructive, handler: nil)        let archiveAction = UIAlertAction(title:"保存", style: UIAlertActionStyle.default, handler: nil)        alertController.addAction(cancelAction)        alertController.addAction(deleteAction)        alertController.addAction(archiveAction)        self.present(alertController, animated:true, completion: nil)    }
0 0
原创粉丝点击