我想讓我的幾個應用程序viewcontrollers在iOS 6.0中不旋轉。 這是我做過什麼,使旋轉的iOS 6可能:iOS 6 ViewController正在旋轉,但不應該
1)設置應用程序的窗口RootViewController的中:didFinishLaunchingWithOptions:
self.window.rootViewController = self.tabBarController;
2)將「支持的界面面向」在我目標(XCode中),這樣我就可以使用所有方向
3)實施新的iOS 6.0旋轉功能
- (BOOL) shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
4.)由於某些原因,我分類UINavigationController並實現了這些新功能,並使用這個新的NavigationController而不是原來的。
到目前爲止,一切正常,所有viewcontrollers現在都可以旋轉到每個方向。現在我想要幾個viewController不旋轉,只留在肖像。但是,當我在那些特定viewcontrollers設置新的輪換方法就是這樣,它仍然旋轉的每一個方向:
- (BOOL) shouldAutorotate {
return NO;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
還設置navigationController的rotationsfunctionality上面一樣沒有任何改變。 (所有viewcontrollers可以旋轉到每個方向)
我在做什麼錯?
編輯:
還設置首選Interfaceorientation不會改變任何東西:
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationMaskPortrait;
}
謝謝,這解決了我的問題! – NicTesla
小心使用此解決方案 - 如果視圖控制器的supportedInterfaceOrientations方法碰巧在導航控制器上調用supportedInterfaceOrientations,則您有無限遞歸。我發現蘋果的UIPrintingProgressViewController嚮導航控制器詢問支持接口方向的方式很難...... – tyler
@tyler我們如何處理這個問題?打印導致無限遞歸。無論如何,我無法修復它。我使用上面的類別來旋轉我的應用程序中的特定視圖控制器。 –