2013-07-20 2 views
2

카메라 앱과 동일하게 작업하고 싶습니다. 세로 모드 만 지원되지만 툴바 및 일부 컨트롤이 같은 위치에있는 동안 특정 뷰를 회전하면 회전됩니다.카메라 앱 지원되는 방향?

PLIST 파일에서 지원되는 모든 방향을 사용하지 못하게했지만 shouldRotate 또는 명시 적으로 willRotate와 같은 대리자 메서드를 호출하지 않아 방향 변경을 수행하지 않습니다.

지원 방향이 PLIST에있는 경우 iPhone이 shouldRotate 메소드에 대해 NO를 반환하더라도 모든보기가 회전합니다.

어떻게 이러한 딜레마를 해결할 수 있습니까?

답변

2

info.plist에는 지원되는 방향 만 Portrait으로 설정하십시오. 그런 다음 viewDidLoad 방법, 추가 :이 메소드를 호출

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 

:

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

    switch(currentDeviceOrientation){ 
    case UIDeviceOrientationPortrait: 
     break; 
    case UIDeviceOrientationPortraitUpsideDown: 
     break; 
    case UIDeviceOrientationLandscapeLeft: 
     break; 
    case UIDeviceOrientationLandscapeRight: 
     break; 
    default: 
     break; 
    } 
} 

을 여기에서, 당신은 당신이 어떤 옵션에 따라 원하는대로 할 수 있습니다. 또한,이를 추가하는 것을 잊지 마세요 : 너에게

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; 

의 dealloc 방법. 희망 그 도움!

+0

감사합니다. 시도해 보겠습니다. – Vad