【发布时间】:2012-09-24 11:04:39
【问题描述】:
我正在尝试让我的一个 xib 文件旋转为纵向,就好像它首先是默认设置一样。
我让我的应用只支持横向。在 plist 中,我将“初始界面方向设置为横向(右主页按钮)”,因为大多数应用程序在横向模式下运行。
我在实现文件中的代码是:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
现在,当更改为需要界面处于纵向模式的视图控制器时,我已将此代码放在 xib 文件的实现文件中,以使其进入纵向模式并单独支持纵向模式。这样即使设备处于横向模式,它仍然会以纵向模式运行视图。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortrait;
}
虽然这似乎不起作用。它只是保持在横向模式并挤压图像视图和我放在 xib 文件中的其他对象。如何让 xib 旋转到纵向模式?谢谢。
【问题讨论】:
-
iOS 6 新增了 3 种方便界面旋转的方法,查看:stackoverflow.com/questions/12404556/…
-
哪个iOS版本以及如何更改viewController?
-
您使用哪种方法来获取视图.. pushviewcontroller 或 presentModalViewController
-
@jcesar 我实际上是从 iOS5 开始我的项目