ViewController将不会出现 - iOS

时间:2014-05-24 10:41:56

标签: ios iphone cocoa-touch viewcontroller presentviewcontroller

我有一个iOS应用程序,它将加载一个特定的视图控制器进行身份验证。但无论如何,视图控制器都不会加载。下面是处理此问题的方法的代码(这是用于游戏中心身份验证弹出窗口):

-(void)authenticateLocalUser {

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

    if (viewController != nil) {
        NSLog(@"AUTH VIEW CONTROLLER");
        [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:viewController animated:YES completion:nil];
    }

    else if (localPlayer.isAuthenticated) {
        NSLog(@"User is authenticated");
    }

    else {
        NSLog(@"Game Center Auth error.");
    }
};
}

正如您所看到的,我已经关注了Apple开发人员的官方文档。但是,此方法的输出始终为:

  

Game Center Auth Error(Last NSLog)。

为什么视图控制器没有加载?因为我需要加载它,以便用户可以登录到Game Center,如果他们还没有这样做的话。

谢谢你的时间,Dan。

1 个答案:

答案 0 :(得分:0)

事实证明,问题最终与游戏中心应用本身有关。我刚刚登录/退出,一切正常。我现在也看到在使用Game Center的其他iOS应用程序中复制了同样的问题。