0

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)")
                }
            }
        }

ご覧のとおりUIAlertViewController、 というタイトルのメソッドで を提示していpresentAlertMessageToUser(message: String?, handler: ((UIAlertAction) -> Void)?)ます。それ自体に問題はないようですが、次の場所で確認できます。

    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 ステートメントのエラー ケースでは、再試行を無効にし、シーケンスのどの部分も複数回実行されていないことも確認しました。コードの他の部分が役立つ場合は、コンソールへの出力とともにここに投稿できます。コンソールでは、これらの印刷行を使用してアプリの進行状況を監視しています。

4

1 に答える 1

0

わかりましたので、これは明らかにばかげた質問でした。自分のアプリの設定(空で空白に見える)ではなく、設定でドロップオフされることを期待していました。

于 2016-07-12T19:25:55.217 に答える