swift中,需要弹出提示框,警告相关信息。
之前搜过相关的内容,得知:
UIAlertView和UIActionSheet
提示都是iOS 8就过期废弃了
然后找到:
代码:
1 2 3 | //alert let loginFailWarningAC = UIAlertController(title: "警告" , message: "登录失败" , preferredStyle: UIAlertControllerStyle.Alert) self.presentViewController(loginFailWarningAC, animated: true , completion: nil) |
效果:
搜:
swift uialertcontroller example
参考:
参考:
1 2 3 4 5 6 | let loginFailWarnAlertController = UIAlertController(title: "警告" , message: "登录失败" , preferredStyle: UIAlertControllerStyle.Alert) let okAlertAction = UIAlertAction(title: "OK" , style: UIAlertActionStyle.Default, handler: nil) loginFailWarnAlertController.addAction(okAlertAction) self.presentViewController(loginFailWarnAlertController, animated: true , completion: nil) |
效果:

暂时就这样了:
如果以后需要加多个按钮,以及在按钮中添加动作,再去参考上面例子继续折腾。
转载请注明:在路上 » [已解决]swift弹出警告提示对话框