2012-11-27 3 views
0

내 앱의 경우 기기가 어쨌든 회전하지만 거꾸로 돌아가도록하고 싶습니다. 이것은 잘 작동합니다. 그러나, 나는iOS6 기기 회전 제한을 받음

풍경에서 특별히 회전에서 응용 프로그램을 중지하려면 왼쪽 -> 풍경 권리 -와 그 반대의 경우도 마찬가지

사람이 그 회전이 그들 각각의로, 내 레이아웃을 망쳐 놨 때문이다, 호기심 경우

일반적인 관점에서 회전

나는 일 것이라고 생각에서 iOS 5,에 대한 나의 코드는 다음과 같다 : 3 = 가로 왼쪽

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 

    NSLog(@"Rotating"); 
    if((lastOrient == 3 && toInterfaceOrientation == 4) || (lastOrient == 4 && toInterfaceOrientation == 3)){ 
     lastOrient = toInterfaceOrientation; 
     return NO; 
    } 

    lastOrient = toInterfaceOrientation; 
    return YES; 

} 

4 = 풍경 권리

iOS6에서이 작업을 수행하는 방법에 대한 제안 사항이 있으십니까? 아니면 전혀 다른 솔루션입니까?

답변

0

내가 여기 내 자신의 질문에 대답 확인 :

좋은 소식은, 확실히 할 수있는 방법이있다! 그래서 기본을 heres :

iOS6에서는 앱이 일반적으로 회전 할 수 있는지 여부를 처리하는 것은 appDelegate까지입니다. 그런 다음 장치가 회전 신호를 받으면 지원되는 방향을 사용자에게 확인합니다. 이것이 내가 코드를 구현 한 곳입니다. 사실 shouldAutorotate()는 솔루션에서 아무런 역할을하지 않습니다.

그래서 나는

-(NSUInteger)supportedInterfaceOrientations 
{ 
    NSLog(@"Last Orient = %d", lastOrient); 
    NSUInteger orientations = UIInterfaceOrientationMaskPortrait; 

    if (lastOrient != 3 && lastOrient != 4) { 
     NSLog(@"All good, rotate anywhere"); 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
    } 
    else if(lastOrient == 3){ 
     orientations |= UIInterfaceOrientationMaskLandscapeRight; 
     NSLog(@"Can only rotate right"); 
    } 
    else if(lastOrient == 4){ 
     orientations |= UIInterfaceOrientationMaskLandscapeLeft; 
     NSLog(@"Can only rotate left"); 
    } 

    return orientations; 
} 

나를 위해 작동하는 것 같다 방향

을 비교할 수있는 마지막 방향 추적 할 수있는 변수를 만들고,

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 

이 방법으로 변경합니다. 약간의 해킹이 있지만 필요한 작업을 수행합니다.

1

shouldAutorotateToInterfaceOrientation은 ios6에서 사용되지 않습니다. 이것을 사용하십시오 :

- (BOOL)shouldAutorotate { 

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; 

if (lastOrientation==UIInterfaceOrientationPortrait && orientation == UIInterfaceOrientationPortrait) { 
return NO; 

} 

return YES; 
} 

이 코드를 테스트하지 않았습니다. 당신은이 게시물에 대한 자세한 정보를 얻을 수 있습니다 shouldAutorotateToInterfaceOrientation is not working in iOS 6 shouldAutorotateToInterfaceOrientation not being called in iOS 6

+0

분명히 구현 (shouldAutorotateToOrientation 및 shouldAutorotate)을 모두 포함 할 수 있으며 ios6에서 캐스케이드해야합니다. – dmoss18