UIAlertController 发疯了,指向应该取消的设置

UIAlertController gone crazy, point to settings when it should cancel

有人曾经有过带有 "cancel" 操作的警报控制器,并且在处理程序中只有 return 做某事吗?

我的转到应用程序设置....

我在另一个 viewcontroller 中有另一个警报控制器可以做到这一点。但这不应该影响这个????

alertControl.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: { (alertAction) -> Void in
            return
        }))

更新:

注释掉所有其他 alertController。 (它们都在其他视图控制器中)现在它不再这样做了。这是什么??

这些也只有在出现问题时才在函数中声明。当没有连接时,...它们甚至不应该存在,除非函数被调用。

更新 2:

func checkAllSettingsForLocation() {
        if isTest != true {
        //println("should show this")

        let alertController = UIAlertController(title: "Scenix can't use your location", message: "Check Location Services under Privacy in the Settings App", preferredStyle: UIAlertControllerStyle.Alert)

        let goToSettingsAction = UIAlertAction(title: "Go to Settings", style: .Default, handler: {
            action in
            UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
            return

            }
        )
        alertController.addAction(goToSettingsAction)

        let ignoreNoCamAction = UIAlertAction(title: "Cancel", style: .Default, handler: {
            action in
            self.launch = self.launch - 1
            return

            }
        )
        alertController.addAction(ignoreNoCamAction)

        self.presentViewController(alertController, animated: true, completion: nil)
        }
    }

更新 3:

看起来越来越像一个 Xcode Bug。

为发布而构建/通过试飞并且存在错误。 进行正常的调试构建,一切正常....


脏修复=>

将来自任何警报控制器的操作包装在检查警报控制器标题的 if 语句中。永远不会抛出异常或导致找到 nil 并解决我的问题。

尝试使用 nil 而不是 return、

let cancel = UIAlertAction(title: "Ok", style: .Cancel, handler: nil) alertController.addAction(cancel)

我还有一些其他设置目标警报控制器,这对我来说效果很好。