您應該在每個視圖控制器中覆蓋:-(BOOL) shouldAutorotate
。如果您希望該視圖控制器以其他方式旋轉NO,則返回YES。一定要檢查故事板設置中支持的方向。
更新:在你父控制器呈現玩家嘗試這個辦法:
- (BOOL)shouldAutorotate
{
// 1. check if the parent presentedViewController is the nav containing the player
// 2. if yes, return YES, NO otherwise
}
如果應用程序根控制器導航控制器,子類UINavigationViewController
和使用該類創建的應用程序根視圖控制器應用代理
@implementation ANavigationViewControllerSubClass
- (BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return [self.topViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
可能重複檢查這個http://stackoverflow.com/questions/19768620/ios-7-restrict-landscape-orientation-only-in-one-view-controller – Rajesh 2014-09-03 06:58:42
是,它的導航控制器。我這樣做:UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:btVC]; self.window.rootViewController = navController;其中btVC是從UIViewController的子類別 – 2014-09-03 07:14:58