gpt4 book ai didi

ios - 尝试从我的应用程序切换到设置,但它似乎又回来了……有点像

转载 作者:行者123 更新时间:2023-11-30 13:14:53 25 4
gpt4 key购买 nike

因此,当我遇到 CKErrorCode.NotAuthenticated 问题时,我使用以下代码行切换到“设置”:

let url = NSURL(string: UIApplicationOpenSettingsURLString)
let result = UIApplication.sharedApplication().openURL(url)

我将立即在上下文中显示代码。 一开始似乎一切顺利(我的应用程序进入后台),但后来我又回到了应用程序的新版本。后退按钮展开到“设置”(它有相应的标签),从那里我可以展开回原始应用程序。除了从“设置”打开的应用程序的迭代无法加载任何内容这一事实(它是标题,但除此之外是空白屏幕),其他一切都正常工作。

这是我第一次创建 XIB,因此可能需要记住这一点。我正在以下情况下触发的 switch 语句中进行错误处理:

        case CKErrorCode.NotAuthenticated.rawValue:

//Should check account status here...

// If account not logged in...
let message = "Your device needs to be logged in to your iCloud Account in order for Voyager to work correctly. After clicking 'OK' you can login at Settings/iCloud..."
presentAlertMessageToUser(message) { action in
if let goToSettingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
print("E3")
dispatch_async(dispatch_get_main_queue()) {
let result = UIApplication.sharedApplication().openURL(goToSettingsURL)
print("E4: \(result)")
}
}
}

如您所见,我在名为 presentAlertMessageToUser(message: String?, handler: ((UIAlertAction) -> Void)?) 的方法中呈现 UIAlertViewController 。它本身似乎没有任何问题,但您可以在这里看到它:

    private func presentAlertMessageToUser(message: String?, handler: ((UIAlertAction) -> Void)?) {
print("G0")
let alert = UIAlertController(title: "Connection Error", message: message, preferredStyle: .Alert)

alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
if let completionBlock = handler {
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: completionBlock))
} else {
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
}
dispatch_async(dispatch_get_main_queue()) {
print("G2")
unowned let me = self
me.presentViewController(alert, animated: true, completion: nil)
}
print("G1")
}

对于 switch 语句中的这种错误情况,我禁用了重试尝试,并且还验证了它没有多次执行序列的任何部分。如果代码的任何其他部分有帮助,我可以将其与输出一起发布到我的控制台,我在控制台中使用这些打印行来监视应用程序的进度。

最佳答案

好吧,这显然是一个愚蠢的问题。我希望在设置中下车,而不是我自己的应用程序的设置(它是空的并且显示为空白)。

关于ios - 尝试从我的应用程序切换到设置,但它似乎又回来了……有点像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38336940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com