당신이 벤처 투자자 사이에서 제시하는 모델을 사용하는 경우, @ 데이비드의 대답은 올바른 것입니다. 푸시/팝 UINavigationController
을 사용하는 경우 작업이 더욱 복잡해집니다.
- (NSUInteger)supportedInterfaceOrientations
및 - (BOOL)shouldAutorotate
은 장치 회전 또는 루트 컨트롤러가 변경된 후에 만 호출 할 수 있습니다. 푸시/팝으로는 만들 수 없습니다. 이
[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationPortrait];
그러나이 사용되지 않습니다 :
iOS5를에서 이전은,하는 API가있다. Apple은 그것을 개인적인 것으로 만듭니다.
objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), @(UIInterfaceOrientationPortrait));
또는
[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationPortrait)
forKey:@"orientation"];
참고 :
당신은 여전히 같은 6 + 아이폰 OS에 전화를 objc 런타임 API를 사용할 수 있습니다 비공개 API이다, 이것은에 의해 거부 될 수 있습니다 App Store. 이것은 - (NSUInteger)supportedInterfaceOrientations
및 - (BOOL)shouldAutorotate
호출 할 수 있도록합니다
[self presentViewController:[UIViewController new]
animated:NO
completion:^{
[self dismissViewControllerAnimated:NO completion:nil];
}];
:
또 다른 교묘 한 방법
, 그냥 다음 빈 VC를 제시
viewDidAppear
에 같은 그것을 기각한다는 것입니다.
위의 내용에 만족하지 않는 경우 나만의 NavigationController를 만들거나 이 질문을 확인하십시오 : Why can't I force landscape orientation when use UINavigationController?.
별도의보기 컨트롤러입니까, 아니면 UIView입니까? – David
별도의 viewController. Alltogether 두 viewControllers.For 두 번째 내가 세로로 제한하고 싶습니다. – user3202087
참조 : http : // stackoverflow.com/questions/18595561/대안 -ios-layouts-for-portrait-and-landscape-using-one-xib-file –