1

Game Center を利用するシンプルな iOS アプリがあります。しかし、最近iOS 7にアップデートしたところ、認証方法が機能しないことに気付きました。

問題の 1 つは、ユーザーがゲーム センターにサインインする必要がある場合にビュー コントローラーを表示するために使用しているコードにあり、アプリでゲーム センターのログイン ウィンドウがポップアップしなくなりました。

私が抱えている別の問題は、非推奨の「authenticateWithCompletionHandler」の代わりに使用するメソッドが見つからないことです。

これが私のコードです:

-(void)authenticateLocalUser {

GKLocalPlayer.localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {

    if (GKLocalPlayer.localPlayer.authenticated) {
        // Already authenticated
    }

    else if (viewController) {
        [self presentViewController:viewController animated:YES completion:nil];
    }

    else {
        // Problem with authentication, probably bc the user doesn't use Game Center.
    } 
};

if ([GKLocalPlayer localPlayer].authenticated == NO) {

    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error)  {
        [self callDelegateOnMainThread: @selector(processGameCenterAuth:) withArg:NULL error: error];
    }];
}
}

時間をありがとう、ダン。

4

1 に答える 1

1

最終的にはなんとか理解できました。「authenticateWithCompletionHandler」に関しては、これを使用しました:

[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:viewController animated:YES completion:nil];
于 2014-06-01T11:29:34.627 に答える