Iphone 无法验证本地播放器iOS6

Iphone 无法验证本地播放器iOS6,iphone,ios,objective-c,ios6,game-center,Iphone,Ios,Objective C,Ios6,Game Center,我正在iOS6中构建一个游戏中心游戏,并且不断遇到问题。当前的一个让我感到困惑——每次我的游戏试图验证本地玩家的身份时,它都失败了。每次它都会触发我的“禁用游戏中心”功能,让我发疯 - (void) disableGameCenter { // Write something to disable gamecenter. // gameCenterAvailable = FALSE; } -(void)showAuthenticationDialogWhenReasonable

我正在iOS6中构建一个游戏中心游戏,并且不断遇到问题。当前的一个让我感到困惑——每次我的游戏试图验证本地玩家的身份时,它都失败了。每次它都会触发我的“禁用游戏中心”功能,让我发疯

- (void) disableGameCenter
{
    // Write something to disable gamecenter.
    // gameCenterAvailable = FALSE;
}

-(void)showAuthenticationDialogWhenReasonable:(UIViewController *)viewController
{
    // Pause Tasks Here
//    [[[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:viewController animated:YES completion:nil];
}

- (void) authenticateLocalPlayer
{
    localPlayer = [GKLocalPlayer localPlayer];
    __weak GKLocalPlayer* weakLocalPlayer = localPlayer;

    weakLocalPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
    {
        if (viewController != nil)
        {
            [self showAuthenticationDialogWhenReasonable: viewController];
        }
        else if (weakLocalPlayer.isAuthenticated)
        {
            self.localPlayer = weakLocalPlayer;
        }
        else
        {
            [self disableGameCenter];
        }
    };
}

如果我错了,请原谅,但我不认为您正在运行身份验证方法

请尝试以下方法:

- (void) authenticateLocalPlayer
{
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    [localPlayer authenticateWithCompletionHandler:^(NSError *error) {
        if (localPlayer.isAuthenticated)
        {
            NSLog(@"Authenticated");
        }
        else
        {
            NSLog(@"Not Authenticated");
        }
    }];
}

也许viewController是nil,但似乎确实如此,我不知道为什么。有什么想法吗?似乎如果身份验证失败了,那么一定是设置了错误。如果你在“disableGameCenter”上设置了一个断点,那么当你打印出来时,“error”中有什么?Logan,试着重置你的设备(先关机,然后再开机),这是我以前的做法,但他们不赞成在iOS6中使用authenticateWithCompletionHandler,从那以后,我一直在努力寻找解决办法。我仍然在iOS 6I上使用这种方法。我刚刚提交了一个应用程序,代码与此完全相同,我没有遇到任何问题。它确实有效,但我希望我知道的东西能够继续有效。