(为什么?如果您从无网络区域移动到网络区域.)
不幸的是,在iOS6 / XCode 4.5下,它开始崩溃了.或者至少在某些有限的情况下似乎:用户无法使用错误的密码和/或不存在的帐户登录.成功登录后,一切顺利.
在登录失败之后,当我去做一些导致进行reauth检查的事情时,我得到了这个:
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]; } ]; } } }
知道我在这里做错了吗?
解决方法
这似乎有效……
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]; } })];