【发布时间】:2010-12-25 20:55:22
【问题描述】:
我正在开发一个有多个笔尖的 iPhone 应用程序,并且应该只是横向的。
应用程序通过其 Info.plist 文件设置为以横向模式启动。
我有两个视图控制器:
FirstViewController 和 SecondViewController。
对于其中的每一个,我都有一个 nib 文件,其中视图是横向的。两个视图控制器都作为插座添加到我的MainView nib 中,并且它们的视图被延迟初始化。
当应用程序加载时,第一个视图按预期显示为横向。但是,当我切换到第二个视图时,设备(或模拟器)仍处于横向状态,但视图会旋转,就好像设备处于纵向模式一样,这会影响我的界面。
在两个UIViewController 类中,我都有以下代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
并在我的应用程序委托中切换视图:
[viewController.view removeFromSuperview];
[window addSubview:secondViewController.view];
其中viewController 和secondViewController 是连接视图控制器的两个出口。
这是第二个视图在 IB 中的样子: alt text http://img27.imageshack.us/img27/4898/picture1ni.png
这是它在模拟器中的样子: alt text http://img402.imageshack.us/img402/4866/picture2wt.png
为什么第二个视图是横向显示但界面是旋转的?
我不想处理转换属性,因为这似乎有点过头了。
【问题讨论】: