【发布时间】:2014-05-07 02:46:08
【问题描述】:
我在使用纯横向应用时遇到了一个奇怪的问题。它可以很好地向左或向右横向旋转,但是当应用启动时它会旋转 180 度,而不是仅仅以正确的方向启动。
我尽我所能在 StackOverflow 和 Google 上找到。信息列表包含:
已测试:iOS 7.1 完全忽略了 plist 中的初始启动方向设置。我左右都试了,然后删除 info plist 中的密钥。没有效果。应用程序总是以横向启动,左侧有主页按钮,忽略此设置。
重试时,我会删除应用并清理构建。
在 App Delegate 中,我有这个:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
在根视图控制器中:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
一些横向应用(例如 Tiny Wings)以正确的方向启动,因此我知道我的项目有问题。让这项工作发挥作用的秘诀是什么?
【问题讨论】: