我正在使用Apples Game Center在游戏开始时让玩家登录,问题是我刚刚点击了取消(最终测试),现在对话框将不再出现,它只是继续直接进入禁用状态。
这是我正在使用的功能。
-(void) setup
{
gameCenterAuthenticationComplete = NO;
if (!isGameCenterAPIAvailable()) {
// Game Center is not available.
NSLog(@"Game Center is not available.");
} else {
NSLog(@"Game Center is available.");
__weak typeof(self) weakSelf = self; // removes retain cycle error
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; // localPlayer is the public GKLocalPlayer
__weak GKLocalPlayer *weakPlayer = localPlayer; // removes retain cycle error
weakPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
{
if (viewController != nil)
{
NSLog(@"Try to show ViewController");
[weakSelf showAuthenticationDialogWhenReasonable:viewController];
}
else if (weakPlayer.isAuthenticated)
{
NSLog(@"authenticate player");
[weakSelf authenticatedPlayer:weakPlayer];
}
else
{
NSLog(@"disable");
[weakSelf disableGameCenter];
}
};
}
}
-(void)disableGameCenter
{
}
如您所见,DisableGameCenter实际上并没有做任何事情。
为什么我现在每次运行它时都会禁用它?(使用模拟器)以及如何摆脱它,以便对话框再次出现?我是否必须以某种方式手动强制对话框再次出现?
我在OSX下遇到了类似的问题,在您"取消"游戏中心对话框几次后,它停止出现。
要将其取回,请运行"Game Center",登录和注销 - 然后再次运行游戏,对话框将再次出现(它至少工作几次,直到您"取消"太频繁)。