装入游戏中心时,其默认方向为纵向。 为了锁定横向模式,添加了一个类别。游戏中心登录锁定只在i OS 6
@implementation GKMatchmakerViewController (LandscapeOnly)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return NO;
}
@end
它在iOS 6以下工作正常,但在iOS6中显示错误。
终止应用程序由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”,理由是:“支持的方向与应用程序中没有共同的方向,并shouldAutorotate将返回YES”
请解释的解决方案。
真棒!你救了我的屁股:) – yonix
谢谢!我的屁股被保存了:) –
也为我工作,但在我的情况下,我没有使用UIBNavigationController而是UIViewController(它的子类),但我仍然必须将方法2添加到它。你可能想在这个答案中用UIViewController替换UIBNavigationController。 –