游戏中心加载时的默认方向为竖屏。为了将其锁定在横屏模式下,添加了一个类别。
@implementation GKMatchmakerViewController (LandscapeOnly)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ( interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return NO;
}
@end
在iOS 6以下版本中运行良好,但在iOS 6上会显示错误。
终止应用程序,原因是未捕获的异常'UIApplicationInvalidInterfaceOrientation':'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'
请解释一种解决方案。