Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 为什么';我的警报视图控制器不能工作吗_Swift_Uialertview - Fatal编程技术网

Swift 为什么';我的警报视图控制器不能工作吗

Swift 为什么';我的警报视图控制器不能工作吗,swift,uialertview,Swift,Uialertview,如果我构建此警报,则不会显示警报视图。我错过了什么 另外,我知道还有一些类似的问题,但要找出它们有什么,我错过了什么是很难的您必须在视图中显示Alert视图 let alert = UIAlertController(title: "Title", message: "message", preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "Cancel", style: UIAle

如果我构建此警报,则不会显示警报视图。我错过了什么


另外,我知道还有一些类似的问题,但要找出它们有什么,我错过了什么是很难的

您必须在视图中显示Alert视图

let alert = UIAlertController(title: "Title", message: "message", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil))
alert.addAction(UIAlertAction(title: "Title", style: UIAlertActionStyle.default, handler: { action in self.alertFunc() }))

您必须在视图上显示Alert视图

let alert = UIAlertController(title: "Title", message: "message", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil))
alert.addAction(UIAlertAction(title: "Title", style: UIAlertActionStyle.default, handler: { action in self.alertFunc() }))

您也需要在当前的上下文中演示它:

self.present(alert, animated: true, completion: nil)
将该行添加到
警报
声明的末尾:

self.present(alert, animated: true, completion: nil)

您也需要在当前的上下文中演示它:

self.present(alert, animated: true, completion: nil)
将该行添加到
警报
声明的末尾:

self.present(alert, animated: true, completion: nil)