2013-07-22 3 views
1

현재 iOS 5의 화면 회전에 문제가 있습니다. iOS 6에서는 모든 것이 정상적으로 작동하지만 회전은 iOS 5에서 작동하지 않습니다. 알림 UIDeviceOrientationDidChangeNotification이 호출 되더라도. 내 ViewController 같은 방법 내가 여기 Storyboard를 사용하고있어iOS 5에서는 화면 회전이 작동하지 않지만 iOS 6에서는 작동 중임

는 다음과 같습니다

CustomTabBarViewController.mm (UITabBarController)

: 나는 다음과 같은 방법을 사용하여 화면을 회전하기 위해

enter image description here

(UINavigationView)

-(BOOL)shouldAutorotate 
{ 
    return [self.topViewController shouldAutorotate]; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return [self.topViewController supportedInterfaceOrientations]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return [self.topViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; 
} 

LoyaltyListController.mm은 (UIViewController)

- (void) didRotate:(NSNotification *)notification 
{ 
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 

    if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) 
    { 
     self.navigationController.navigationBarHidden = YES; 
     [self hideTabBar:self.tabBarController]; 
     portraitView.hidden = YES; 
     landscapeView.hidden = NO; 
    } 
    else if (orientation == UIDeviceOrientationPortrait) 
    { 
     self.navigationController.navigationBarHidden = NO; 
     [self showTabBar:self.tabBarController]; 
     portraitView.hidden = NO; 
     landscapeView.hidden = YES; 
     [notificationView setFrame:CGRectMake(0, - (notificationView.frame.size.height + 40), notificationView.frame.size.width, notificationView.frame.size.height)]; 
    } 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 
    [(CustomTabBarViewController*)[self tabBarController] setLandscapeOK:YES]; 
} 

- (BOOL)shouldAutorotate { 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationMaskAllButUpsideDown); 
} 

그리고 여기가에서 iOS 5의 화면은 다음과 같습니다

세로 :

enter image description here

풍경 : (하지 않았다 회전)

enter image description here

어떤 생각 : 여기 16,

enter image description here

는 같아야 무엇인가?

아이폰 OS 6에서 iOS 5를 사용 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)

를 들어

답변

1

, 그 사용되지 않는하지만 당신이 그것을 사용하는 경우가 늘 문제. iOS 5.0 이하에서만 호출됩니다.

업데이트 : UIInterfaceOrientationMaskAllButUpsideDown는 UIInterfaceOrientation의 열거 형 아닙니다. 마스킹이 지원하려는 방향의 조합을 제공하기 위해 마스크 값을 제공하는 아이폰 OS 6에 사용되지만, 아이폰 OS에서 5

당신은 interfaceOrientaion가 있는지 확인해야합니다

UIInterfaceOrientationLandscapeLeft,UIInterfaceOrientationLandscapeRight, UIInterfaceOrientationPortrait or UIInterfaceOrientationPortraightUpsideDown. 

중 하나와 모든 오리엔테이션을 지원할 것인지에 따라 YES 또는 NO를 반환하십시오.귀하의 경우 사용에

:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
/* If you are supporting all, simply return YES, 

if you aren't supporting any return NO, otherwise Use || and check which ones you wanna return YES for. 
In this case you wanna support all except UpsideDown hence use this. */ 
} 
+0

당신이 내 소스 코드를 확인 했습니까 ??? 그게 정확히 내가 사용하는거야. ... '- (BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation) interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationMaskAllButUpsideDown); }' – Jeremy

+0

오, 완전히 놓쳤습니다. 다시 확인하십시오! UIInterfaceOrientationMaskAllButUpsideDown을 사용하지 마십시오. interfaceOrientaion 값에 따라 YES 또는 NO 만 리턴하면됩니다. ||을 (를) 사용해야합니다. 그리고 당신이 지원하고 싶은 모든 것을보십시오. upsidedown을 제외한 모든 것을 지원하기 때문에이 방법으로 코드를 작성했습니다. –

+0

사실,'UIInterfaceOrientationMaskAllButUpsideDown'이 iOS6 이상인 것은 아닙니다 :) 지금 테스트 해 보겠습니다. – Jeremy

-1

당신이 5 이전 및 iOS에서의 지원 중단 및 모든 방향 아이폰 OS를 지원하기 위해 YES를 반환 할 필요가 아이폰 OS 6에 호출되는, 당신은 이미 제대로 iOS6의 방법

구현
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 
+0

내 소스 코드를 확인 했습니까 ??? 그것은 정확히 내가 사용하고있는 무슨 ... '- (BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation) interfaceOrientation { 리턴 (interfaceOrientation == UIInterfaceOrientationMaskAllButUpsideDown); }' – Jeremy

관련 문제