iOS 5 및 iOS 6을 대상으로하는 앱을 만들었으며 어떤 이유로 iOS 6이 장착 된 기기에서 사용할 때만 회전합니다. iOS 5를 사용하는 기기에서는 회전하지 않습니다. 내 앱은 범용입니다. 이 문제를 해결하도록 도와주세요! 감사합니다.앱이 iOS 6에서만 회전하고 iOS 5에서는 회전하지 않습니다.
답변
iOS 5 및 iOS 6은 다른 방향 및 회전 위임자를 호출합니다. 에서 iOS 5에서 구현 : 아이폰 OS 6, 6
그래서 아이폰 OS에서 더 이상 사용되지 않습니다
shouldAutorotateToInterfaceOrientation :를, 당신이 루트 뷰 컨트롤러를 설정하고 구현해야합니다 :
shouldAutorotate :, supportedInterfaceOrientations을 및 supportedInterfaceOrientationsForWindow :
비슷한 문제가있었습니다. 당신은이 질문의 답변을 확인할 수 있습니다
Rotation behaving differently on iOS6
가 자동 회전이 완전히에서 iOS 5 및 iOS 6, 또한 처리 PortraitUpsideDown 방향으로 작동하도록, 요약하기를, 나는 사용자 지정은 UINavigationController를 구현에 할당했다 응용 프로그램의 self.window.rootViewController
은 didFinishLaunchingWithOptions
메서드를 위임합니다.
shouldAutorotateToInterfaceOrientation은 ios6에서 사용되지 않습니다. 당신이 두 OS 버전에 응용 프로그램을 실행하는 wnat 경우
그럼 너무으로는 모두의 UIViewController 서브 클래스에서
//for ios6
- (BOOL)shouldAutorotate {
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIInterfaceOrientationLandscapeLeft ||orientation == UIInterfaceOrientationLandscapeRight)
{
return YES;
}
return NO;
}
//for ios5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//interfaceOrientation == UIInterfaceOrientationLandscapeRight;
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
return YES;
}
return NO;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
오버라이드 (override)하는 두 가지 방법을 다음과 shouldAutorotateToInterfaceOrientation를 추가 ......이 작동됩니다 ios6 및 이전 버전
ios5 및 ios6에서 자동 실행을 지원하려면 ios6의 경우 콜백을 제공해야합니다. [[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
우리는 iOS5를
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{ 리턴 ((toInterfaceOrientation == UIInterfaceOrientationPortrait)에 대한
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutoRotate{
return YES;
}
를 호출 할 필요가 || (toInt erfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); }
흠 ... 이미 포맷하지 않았습니까? 아니, 그것은 또 다른 사본이었습니다 : 그래서 여러 질문에 똑같은 답변을 게시하지 마십시오. 모든 사람에게 적합하지 않거나 질문이 중복되어 표시되어야합니다. – kleopatra
참고 :이 예제는 '직립'(세로)과 '거꾸로'(세로 위 쪽) 두 가지 상태 만 지원합니다. – Gonen