最新消息:20210917 已从crifan.com换到crifan.org

[已解决]swift弹出警告提示对话框

Swift crifan 4041浏览 0评论

swift中,需要弹出提示框,警告相关信息。

之前搜过相关的内容,得知:

UIAlertView和UIActionSheet

提示都是iOS 8就过期废弃了
然后找到:
代码:
            //alert
            let loginFailWarningAC = UIAlertController(title: "警告", message: "登录失败", preferredStyle: UIAlertControllerStyle.Alert)
            self.presentViewController(loginFailWarningAC, animated: true, completion: nil)

效果:

popup warning failed window

搜:

swift uialertcontroller example
参考:
参考:
            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)
效果:
popup alert window for ok
暂时就这样了:
如果以后需要加多个按钮,以及在按钮中添加动作,再去参考上面例子继续折腾。

转载请注明:在路上 » [已解决]swift弹出警告提示对话框

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
96 queries in 0.190 seconds, using 23.33MB memory