更新到Xcode 4.5,横向方向不起作用,并且所提出的解决方案都没有解决问题

时间:2012-09-24 23:33:23

标签: objective-c xcode ios6

我有一个仅限横向的应用程序,当我运行模拟器时,设备将旋转到横向模式,但屏幕正在尝试以纵向模式显示。

以下是我已经尝试过的步骤

我的根视图控制器是一个导航控制器,所以我将其子类化并添加了

- (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;

}

还有其他解决方案吗?

1 个答案:

答案 0 :(得分:1)

我将return UIInterfaceOrientationMaskLandscape更改为return UIInterfaceOrientationMaskLandscapeLeft并且工作正常。不知道为什么会这样。