0

让 Game Center 身份验证工作,但当 Game Center 'Welcome' 视图控制器出现在视图中时,它不会关闭。点击取消,取消操作被发送,但视图控制器仍保留在视图中。完成用户登录,用户已成功登录,但视图控制器仍然存在,创建一个新的 appleID,最后完成时视图控制器仍然存在。

为什么 Game Center 视图控制器不关闭?

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

        if (viewController != nil) {

            [self.navigationController pushViewController:viewController animated:YES];

        } else if (blockLocalPlayer.isAuthenticated) {

             NSLog(@"Game Center Authenticated");
             [self loginUser:blockLocalPlayer];

        } else {

             NSLog(@"Game Center Disabled");
             [self loginUser:nil];
        }

        if (error) NSLog(@"Error authenticating Game Center: %@", error);
     };
4

1 回答 1

0

回答:

代替:

[self.navigationController pushViewController:viewController animated:YES];

应该使用:

[self presentViewController:viewController animated:YES completion:^{}];
于 2013-04-10T16:21:27.030 回答