게임 센터가로드 될 때 기본 방향은 세로입니다. 가로 모드로 잠 그려면 카테고리를 추가하십시오.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를 추가했다. 이 대답에서 UIBNavigationController를 UIViewController로 바꿀 수 있습니다. –