【发布时间】:2012-03-01 22:41:51
【问题描述】:
我有一个奇怪的问题。我的应用程序一直以横向模式启动。如果我在模拟器中打开它,它会自动旋转到横向模式。当我在 iPhone 上启动它时,它首先以横向模式启动,然后在旋转到正确位置后不久。我已将 .plist 中的“初始界面方向”设置为纵向,但没有任何改变。
【问题讨论】:
标签: objective-c ios orientation screen-orientation device-orientation
我有一个奇怪的问题。我的应用程序一直以横向模式启动。如果我在模拟器中打开它,它会自动旋转到横向模式。当我在 iPhone 上启动它时,它首先以横向模式启动,然后在旋转到正确位置后不久。我已将 .plist 中的“初始界面方向”设置为纵向,但没有任何改变。
【问题讨论】:
标签: objective-c ios orientation screen-orientation device-orientation
在 XCode 6.4 中,我只是取消选中所有 4 个设备方向,并在目标应用程序的部署信息中从纵向开始重新选择它们。显然,它们在此处检查的顺序控制了 plist 文件中值的顺序。
【讨论】:
如果只支持横向,写代码
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
它对我有用。
【讨论】:
UIInterfaceOrientation 设置为Supported interface orientation 中的项目0。看起来这与提出的问题不匹配
我遇到了同样的问题。如果您转到 Supported Interface Orientations,您会看到 项目 0 ... 第 1 项 ...
等等。 如果您编辑此列表以使 Portrait(底部主页按钮)成为列表中的第一项,则您的应用将以纵向模式打开。您仍然可以支持其他方向作为项目 1 到 3。
【讨论】:
-(BOOL) shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }。它可以防止您的应用在启动期间进入横向模式。
转到您支持的设备方向并检查您是否选择了纵向模式
【讨论】: