Iphone iOS 6中的游戏中心出现问题

Iphone iOS 6中的游戏中心出现问题,iphone,cocoa-touch,ios6,game-center,Iphone,Cocoa Touch,Ios6,Game Center,我使用此代码登录game center中的用户帐户: [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { if (error != nil) { NSLog(@"LOGIN"); } else { NSLog(@"CANT LOGIN"); }

我使用此代码登录game center中的用户帐户:

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error)
     {
         if (error != nil)
         {
             NSLog(@"LOGIN");
         } else {
             NSLog(@"CANT LOGIN");
         }
     }];
这段代码在iOS 5.x上运行良好,但在iOS 6上崩溃,如果您能帮助修复,我将不胜感激

谢谢

给你

这是您必须在iOS6中对用户进行身份验证的方式:

- (void) authenticateLocalPlayer
{
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
         if (viewController != nil)
         {
             [self showAuthenticationDialogWhenReasonable: viewController
         }
         else if (localPlayer.isAuthenticated)
         {
             [self authenticatedPlayer: localPlayer];
         }
         else
         {
             [self disableGameCenter];
         }
     }];
}
您还应该结帐,因为您的应用程序可能会因为自动旋转问题和游戏中心而崩溃,而不是身份验证机制本身

这是您必须在iOS6中对用户进行身份验证的方式:

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

您还应该签出,因为您的应用程序可能由于自动旋转问题和游戏中心而崩溃,而不是身份验证机制本身。您需要检查iOS5或IOS6。iOS6更改了身份验证功能

损失6

损失5


您需要检查iOS5或ios6。iOS6更改了身份验证功能

损失6

损失5

这在iOS 6中起作用:

        GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
        if (viewController != nil) {
            [self presentViewController:viewController animated:YES completion:nil];
        } else if (localPlayer.isAuthenticated) {
            // do post-authentication work
        } else {
            // do unauthenticated work, such as error message, etc
        }
    };
这在iOS 6中起作用:

        GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {
        if (viewController != nil) {
            [self presentViewController:viewController animated:YES completion:nil];
        } else if (localPlayer.isAuthenticated) {
            // do post-authentication work
        } else {
            // do unauthenticated work, such as error message, etc
        }
    };

此方法在iOS 6中不推荐使用;改为设置
authenticateHandler
属性。(这可能无法修复您的崩溃。为此,您需要显示更多代码。)这是我登录GameCenter的代码!(up),你能给我一个示例代码吗?这个方法在iOS 6中不推荐使用;改为设置
authenticateHandler
属性。(这可能无法修复您的崩溃。为此,您需要显示更多代码。)这是我登录GameCenter的代码!(向上),你能给我一个示例代码吗?非常感谢Lio,这个代码在iOS 5和iOS 6上一起工作?我的游戏在iOS 5上运行得非常好。我希望我的游戏工作在iOS 5和iOS 6一起!请帮帮我,我有不可抗力的工作。看到这个错误了吗:这些错误是因为我粘贴的代码是示例代码,实际上您必须实现这些方法。要回答前面的方法,不,代码只在iOS6中工作。我在iOS6中使用旧的iOS5代码,它仍然可以正常工作。你应该追踪坠机事件并找出原因。我建议你们研究一下我在回答中提到的那个问题。好运气这是从苹果的游戏中心编程指南复制/粘贴的:,它本身包含一个错误。非常感谢Lio,这段代码在iOS 5和iOS 6上一起工作?我的游戏在iOS 5上运行得非常好。我希望我的游戏工作在iOS 5和iOS 6一起!请帮帮我,我有不可抗力的工作。看到这个错误了吗:这些错误是因为我粘贴的代码是示例代码,实际上您必须实现这些方法。要回答前面的方法,不,代码只在iOS6中工作。我在iOS6中使用旧的iOS5代码,它仍然可以正常工作。你应该追踪坠机事件并找出原因。我建议你们研究一下我在回答中提到的那个问题。好运气这是从苹果的游戏中心编程指南复制/粘贴的,它本身包含一个错误。