我有一个仅限横向的应用程序,当我运行模拟器时,设备将旋转到横向模式,但屏幕正在尝试以纵向模式显示。
以下是我已经尝试过的步骤
我的根视图控制器是一个导航控制器,所以我将其子类化并添加了
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
return YES;
}
我也尝试过对单个视图控制器执行此操作,但没有结果。
这就是我在app delegate中的内容
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
home = [[Home alloc] initWithNibName:@"Home" bundle:nil];
navController = [[NavControllerSubClass alloc] initWithRootViewController:home];
[self.window setRootViewController:navController];
// used to be [self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
return YES;
}
还有其他解决方案吗?
答案 0 :(得分:1)
我将return UIInterfaceOrientationMaskLandscape
更改为return UIInterfaceOrientationMaskLandscapeLeft
并且工作正常。不知道为什么会这样。