Sha*_*shi 2 uitableview ios swift uialertcontroller
这是我在一个按钮内编码的内容UITableViewCell.
var shareAlert = UIAlertController(title: "Post Alert",
message: "Your Post has been Shared with your Friends",
preferredStyle: UIAlertControllerStyle.Alert)
var Ok = UIAlertAction(title: "Ok",
style: UIAlertActionStyle.Default,
handler: nil)
shareAlert.addAction(Ok)
shareAlert.presentViewController(shareAlert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
当用户单击按钮时,我希望它显示此警报,但是一旦我单击按钮,应用程序就会崩溃.我做错了吗?如何从按钮中显示警报视图UITableViewCell?
因为这条线而坠毁了
shareAlert.presentViewController(shareAlert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
控制器不能出现,所以
更换
shareAlert.presentViewController(shareAlert, ...)
Run Code Online (Sandbox Code Playgroud)
通过
yourCurrentViewController.presentViewController(shareAlert, ...)
Run Code Online (Sandbox Code Playgroud)
并且您不应该使用UIAlertView,因为它在iOS 9中已被弃用,并且可能在下一个iOS中被淘汰,因此使用UIAlertController并且您不必在不久的将来更改它
| 归档时间: |
|
| 查看次数: |
1788 次 |
| 最近记录: |