我的 UIAlertView 不会从 UISplitViewController 的 MasterViewController 中解散

My UIAlertView won't dismiss from MasterViewController of UISplitViewController

我的 MasterViewController 中有以下代码:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(false);
    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    if((appDelegate.firstTime) != nil){
        self.displayFirstTimeAlert()
    }
}

它尽职尽责地显示警报:

    func displayFirstTimeAlert(){

        let message = "Please go to settings and set your preferred zipcode."
        let alertView = UIAlertView(title: "Welcome", message: message, delegate: nil, cancelButtonTitle: "Dismiss")
        alertView.show()
}

但是当我点击关闭时没有任何反应?这是怎么回事?

我不知道为什么你上面的代码不起作用,因为我测试了它,它实际上被忽略了。但是,您真的不应该再使用 UIAlertView,因为它已被弃用... UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead

所以尝试以这种方式显示警报...

func displayFirstTimeAlert(){
    let message = "Please go to settings and set your preferred zipcode."
    var alert = UIAlertController(title: "Welcome", message: message, preferredStyle: UIAlertControllerStyle.Alert)
    alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default, handler: nil))
    self.presentViewController(alert, animated: true, completion: nil)
}