2013-04-08 3 views
0

앱에서 세로 및 세로 모드 다운 모드에서 회전해야하는 앱이 있습니다. (모든 회전은 요약 패널에서 사용할 수 없습니다.)iOS 6에서는 자동으로 회전 할 수 없습니다.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return interfaceOrientation==UIInterfaceOrientationPortrait || interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown; 
} 

또는

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

을 아무리 내가 6

것 I를 IOS accure하는 회전을 얻을 수 없었다 뭘하려 지금까지 해봤 :

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

-(NSInteger)supportedInterfaceOrientations{ 
NSInteger mask = 0; 
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight]) 
    mask |= UIInterfaceOrientationMaskLandscapeRight; 
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft]) 
    mask |= UIInterfaceOrientationMaskLandscapeLeft; 
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortrait]) 
    mask |= UIInterfaceOrientationMaskPortrait; 
if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown]) 
    mask |= UIInterfaceOrientationMaskPortraitUpsideDown; 
return mask; 
} 

내 AppDelegate에이 퍼팅 시도 :

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    return UIInterfaceOrientationMaskPortraitUpsideDown; 
} 

하지만이 오류 받고 있어요 : 때문에, 이유 캐치되지 않는 예외 'UIApplicationInvalidInterfaceOrientation'응용 프로그램 종료를 '지원 방향은 응용 프로그램과 공통 방향이 없으며, shouldAutorotate가 반환 YES'

이 퍼팅 시도 내 대리자 :

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    NSUInteger orientations = UIInterfaceOrientationMaskAll; 

    if (self.window.rootViewController) { 
     UIViewController* presented = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject]; 
     orientations = [presented supportedInterfaceOrientations]; 
    } 
    return orientations; 
} 

나는 모든 그것에 대해 토론과 shouldAutorotateToInterfaceOrientation의 중단 된 읽기하지만 난 여전히 동작하지 않습니다. 나는 그것을 애플의 아이폰 OS 6 SDK 릴리스 노트에서

+0

하나의 카테고리를 만들고 방향을 처리하십시오. 나를 위해 그것의 일 벌금. – Ganapathy

+0

이렇게 할 수있는 방법을 알려주시겠습니까? – Segev

+0

메서드를 제거하고 코드를 추가하고 알려주세요 - (BOOL) shouldAutorotate { return YES; } - (NSInteger) supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } – Spynet

답변

2

을 잃게 해요

:

Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate methods.

More responsibility is moving to the app and the app delegate. Now, iOS containers (such as UINavigationController) do not consult their children to determine whether they should autorotate. By default, an app and a view controller’s supported interface orientations are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

A view controller’s supported interface orientations can change over time—even an app’s supported interface orientations can change over time. The system asks the top-most full-screen view controller (typically the root view controller) for its supported interface orientations whenever the device rotates or whenever a view controller is presented with the full-screen modal presentation style. Moreover, the supported orientations are retrieved only if this view controller returns YES from its shouldAutorotate method. The system intersects the view controller’s supported orientations with the app’s supported orientations (as determined by the Info.plist file or the app delegate’s application:supportedInterfaceOrientationsForWindow: method) to determine whether to rotate.

The system determines whether an orientation is supported by intersecting the value returned by the app’s supportedInterfaceOrientationsForWindow: method with the value returned by the supportedInterfaceOrientations method of the top-most full-screen controller. The setStatusBarOrientation:animated: method is not deprecated outright. It now works only if the supportedInterfaceOrientations method of the top-most full-screen view controller returns 0. This makes the caller responsible for ensuring that the status bar orientation is consistent.

For compatibility, view controllers that still implement the shouldAutorotateToInterfaceOrientation: method do not get the new autorotation behaviors. (In other words, they do not fall back to using the app, app delegate, or Info.plist file to determine the supported orientations.) Instead, the shouldAutorotateToInterfaceOrientation: method is used to synthesize the information that would be returned by the supportedInterfaceOrientations method.

당신이 당신의 전체 응용 프로그램은 다음 지원하기 위해의 Info.plist를 설정해야 회전하려면 모든 방향. 특정 뷰를 인물 사진으로 만 만들려면 일종의 하위 클래스를 수행하고 세로 방향으로 만 돌아가려면 자동 회전 방법을 재정의해야합니다. 그냥 좀 봐 How to force a UIViewController to Portrait orientation in iOS 6

+0

나의 표적 여름은 모든 방향을 지원하도록 설정되어 있습니다. Info.plist는 모든 방향을 지원하도록 설정되어 있습니다. – Segev

+0

내 UINavigationController 하위 클래스에 대한 링크에 메서드를 추가했는데 함수가 호출되는 것을 볼 수 있지만 내 장치를 플립해도 화면이 세로 모드로 유지됩니다 – Segev

+0

오 .. 발생했습니다. 잠깐, 내 대답을 수정하겠습니다. –

1

내 응용 프로그램은 IOS 5에서 타겟팅됩니다. IOS 5 장치의 shouldAutorotateToInterfaceOrientation 메서드 (기본값)를 사용했습니다. 그리고 카테고리 UINavigationController가 (내 응용 프로그램에서 사용되는 모든 이상 UR 지혜로 사용자 정의 할 수 있습니다.) 대상의 속성을 확인

#import "UINavigationController+Rotation_IOS6.h" 

    @implementation UINavigationController (Rotation_IOS6) 

    -(BOOL)shouldAutorotate 
    { 

      return YES; 
    } 

    -(NSUInteger)supportedInterfaceOrientations 
    { 

     return UIInterfaceOrientationMaskAll; 
    } 

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
    { 
     if([self.visibleViewController isMemberOfClass:NSClassFromString(@"SampleViewController")]) 
     { 
      return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortraitUpsideDown | UIInterfaceOrientationMaskPortrait; 
     } 
     return UIInterfaceOrientationPortrait; 

    } 

    @end 
+0

위의 코드를 UINavigationController 하위 클래스에 추가했는데'supportedInterfaceOrientations'가 호출되었지만 방향이 변경되지 않습니다. – Segev

0

IOS 6의 방향을 처리하기 위해 ... 아래

enter image description here

0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
    return YES; 
} 
처럼
관련 문제