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 방법. 희망 그 도움!
감사합니다. 시도해 보겠습니다. – Vad