由于Game Center,应用程序在飞行模式下崩溃

时间:2014-10-28 23:06:59

标签: ios xcode crash game-center airplane

所以我有一个使用Game Center的游戏,我使用了tutorial online.它在View加载时对用户进行身份验证。要查看排行榜和成就,请按一个按钮,该代码与身份验证分开。一切正常,直到我以飞行模式启动应用程序。出于某种原因,由于它无法连接到Game Center服务器,因此它会放弃并崩溃。

验证码(ViewController.m,viewDidLoad)

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

    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    [localPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error) {


    })];

} else {


    NSLog(@"Already authenticated!");


}

另外,我认为这不会导致问题,因为它在启动时崩溃,我不知道这个代码是否在启动时运行。 (我从教程中复制了大部分代码),但这里是:

(GCHelper.m)

    #pragma mark Authentication

- (void)authenticationChanged {
    if ([GKLocalPlayer localPlayer].isAuthenticated && !userAuthenticated) {
        NSLog(@"Authentication changed: player authenticated.");
        userAuthenticated = TRUE;

        [self loadLeaderBoardInfo];
 //       [self loadAchievements];

    } else if (![GKLocalPlayer localPlayer].isAuthenticated && userAuthenticated) {
        NSLog(@"Authentication changed: player not authenticated.");
        userAuthenticated = FALSE;
    }
}

- (void)authenticateLocalUserOnViewController:(UIViewController*)viewController
                            setCallbackObject:(id)obj
                            withPauseSelector:(SEL)selector
{
    if (!gameCenterAvailable) return;
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

    NSLog(@"Authenticating local user...");
    if (localPlayer.authenticated == NO) {
        [localPlayer setAuthenticateHandler:^(UIViewController* authViewController, NSError *error) {
            if (authViewController != nil) {
                if (obj) {
                    [obj performSelector:selector withObject:nil afterDelay:0];
                }

                [viewController presentViewController:authViewController animated:YES completion:^ {
                }];
            } else if (error != nil) {
                // process error
            }
        }];
    }
    else {
        NSLog(@"Already authenticated!");
    }
}

我的问题是,为什么在飞机模式下发射时会崩溃?这是错误消息:

  

2014-10-28 16:18:05.895 Rock Paper Scissors Challenge [10372:704073]    - [GKLocalPlayerInternal name]:无法识别的选择器发送到实例0x7ced9750

     

2014-10-28 16:18:05.992 Rock Paper Scissors Challenge [10372:704073]    *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [GKLocalPlayerInternal name]:   无法识别的选择器发送到实例0x7ced9750'   * 首先抛出调用堆栈:

100%的时间在飞机模式下崩溃,100%的时间都在工作,当我不在飞机模式时它会说“欢迎回来”我没有得到它

请帮助,谢谢!

0 个答案:

没有答案