2

我已经检查了这个问题的其他解决方案,但没有一个对我有用。

如果我尝试在我的物理 iPhone(不是模拟器;这在模拟器中工作)上验证 GKLocalPlayer,我会收到以下错误:

Terminating app due to uncaught exception 
'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has
no common orientation with the application, and shouldAutorotate is returning YES'

*** First throw call stack:
(0x373463e7 0x33d7e963 0x37346307 0x3815b857 0x382fff21 0x381dfcdd
0x381def6b 0x37349ad4 0x372a128f 0x382fd0f3 0x32acce01 0x30a19793
0x30a195db 0x30a1ce45 0x3731a1b1 0x3728d23d 0x3728d0c9 0x315d733b
0x38147291 0x101a73 0x1019d0)

我试图将以下代码添加到视图控制器,但没有任何变化:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

这个应用程序应该只在横向运行,我可以确认它只在我尝试通过 Game Center 对玩家进行身份验证时发生。如果我把那条线去掉,就没有问题了。

编辑

为了澄清,当以下代码运行时会发生这种情况:

- (void)GKLogin
{
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    [localPlayer authenticateWithCompletionHandler:^(NSError *error) {
        if (localPlayer.isAuthenticated)
        {
            NSLog(@"Authenticated");
        }
        else
        {
            NSLog(@"Not Authenticated");
        }
    }];
}
4

1 回答 1

2

在应用程序委托中试试这个

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

return (NSUInteger)[application supportedInterfaceOrientationsForWindow:window] | (1<<UIInterfaceOrientationPortrait);

}
于 2013-01-26T03:29:54.863 回答