UIAlertView 已弃用?
UIAlertView deprecated?
我想使用带有 "Ok" 按钮的警告框 return 到上一个视图控制器。
我使用这个代码:
let alert = UIAlertView(title: "",
message: "bla",
delegate: nil,
cancelButtonTitle: "OK")
alert.show()
但是 Xcode 说它已被弃用,所以我试过了:
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Button", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
但是警告框不会显示...
有什么想法吗?
如果你使用 swift 3 你可以试试这个:
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Button", style: UIAlertActionStyle.Default, handler: nil))
self.present(alert, animated: true, completion: nil)
查看 here 了解更多详情。
我想使用带有 "Ok" 按钮的警告框 return 到上一个视图控制器。
我使用这个代码:
let alert = UIAlertView(title: "",
message: "bla",
delegate: nil,
cancelButtonTitle: "OK")
alert.show()
但是 Xcode 说它已被弃用,所以我试过了:
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Button", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
但是警告框不会显示... 有什么想法吗?
如果你使用 swift 3 你可以试试这个:
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Button", style: UIAlertActionStyle.Default, handler: nil))
self.present(alert, animated: true, completion: nil)
查看 here 了解更多详情。