问题:如果用户未登录GameCenter帐户 - GameCenter身份验证视图以纵向模式启动(在ios 5中有一个模式对话框)要求登录.但是如果我在xcode(项目摘要)或supportedInterfaceOrientationsForWindow中禁用纵向模式: (因为我的应用程序应该只在横向模式下运行)我得到:
由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'
如果我为ipad/iphone启用了肖像(和/或注释掉了supportedInterfaceOrientationsForWindow :),它可以正常工作而不会崩溃,但我不希望启用纵向模式.
加载游戏中心时,其默认方向为纵向.为了将其锁定在横向模式中,添加了一个类别.
@implementation GKMatchmakerViewController (LandscapeOnly)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ( interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return NO;
}
@end
Run Code Online (Sandbox Code Playgroud)
它在iOS 6下面工作正常.但在iOS6中显示错误.
由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'
请解释一下解决方案.