gpt4 book ai didi

ios - GKLocalPlayer Auth 在 iOS6 上崩溃并出现模态转换错误

转载 作者:可可西里 更新时间:2023-11-01 03:40:08 24 4
gpt4 key购买 nike

我的应用会记录它是否成功通过 Game Center 的身份验证。当它开始新游戏或当用户查看得分列表时,如果本地玩家未成功通过身份验证,并且如果该应用当时未在尝试对用户进行身份验证,它会再次尝试.

(为什么?如果您已从无网络区域移动到网络区域。)

不幸的是,在 iOS6/XCode 4.5 下,它开始崩溃了。或者至少在某些有限的情况下似乎是这样:当用户使用错误的密码和/或不存在的帐户无法登录时。成功登录后,一切正常。

在登录失败后,当我去做一些导致重新验证检查发生的事情时,我得到了这个:

2012-09-25 15:54:47.829 APP NAME [1493:907] * Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit/UIKit-2372/UIWindowController.m:211

然后这实际上崩溃了:

2012-09-25 15:55:25.569 APP NAME [1493:907] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <GKModalRootViewController: 0x1cd8b2a0> to <GKHostedAuthenticateViewController: 0x1e31a350> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed' * First throw call stack: (0x394932a3 0x31db297f 0x3949315d 0x383fd2af 0x3640377b 0x36402fcf 0x394969c4 0x393edfeb 0x36521733 0x32a83d2d 0x3264b11f 0x3264a4b7 0x3264f1bd 0x39466f3b 0x393d9ebd 0x393d9d49 0x353132eb 0x3636b301 0x7e863 0x7e808) libc++abi.dylib: terminate called throwing an exception

这是麻烦的代码:

-(void)authenticateLocalUser {

if (!self.checkingLocalPlayer) {
self.checkingLocalPlayer = YES;
GKLocalPlayer *thisPlayer = [GKLocalPlayer localPlayer];

if (!thisPlayer.authenticated) {

[[GKLocalPlayer localPlayer]
authenticateWithCompletionHandler:^(NSError *error)
{
[self finishGameCenterAuthWithError:error];
}
];
}
}
}

知道我在这里做错了什么吗?

最佳答案

Ggrrrhhh 同样的问题,我想我发现了...ios6 已弃用 authenticateWithCompletionHandler 查看链接,建议您使用 AuthenticateHandler。

http://developer.apple.com/library/IOS/#documentation/GameKit/Reference/GKLocalPlayer_Ref/Reference/Reference.html#//apple_ref/occ/instp/GKLocalPlayer/authenticateHandler

这似乎有效...

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

//[localPlayer authenticateWithCompletionHandler:^(NSError *error) { OLD CODE!
if (localPlayer.isAuthenticated)
{
//do some stuff
}
else {

UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"NOT AUTHORISED"
message:@"YOUR'RE NOT LOGGED INTO GC."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];

}
})];

关于ios - GKLocalPlayer Auth 在 iOS6 上崩溃并出现模态转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12592346/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com