我在 AppStore 上有一个应用程序,它在 iPhone 上具有纵向模式,在 iPad 上它适用于横向模式。但是,我收到报告称它在 iPad 1 上显示肖像,因此破坏了整体视图。
为什么 iPad 1 专门显示纵向模式?iPad的版本是5.1.1
我在 AppStore 上有一个应用程序,它在 iPhone 上具有纵向模式,在 iPad 上它适用于横向模式。但是,我收到报告称它在 iPad 1 上显示肖像,因此破坏了整体视图。
为什么 iPad 1 专门显示纵向模式?iPad的版本是5.1.1
在 ios 6 中,支持界面方向的方法已经改变。为了在两个版本中都支持两种界面方向,我们需要检查操作系统版本并相应地编写代码。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
支持新版本
- (NSUInteger)supportedInterfaceOrientations {
}
- (BOOL)shouldAutorotate {
}
在我的视图控制器中,我有以下内容:
- (NSUInteger)supportedInterfaceOrientations {
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
}
- (BOOL)shouldAutorotate {
}
去确保所有视图控制器都返回它们支持的正确方向模式。我在 iOS 5 中看到过这种行为,如果我没记错的话,这就是原因。
我有一个非常相似的问题,我通过更改 AppDelegate.m-> applicationDidFinishLaunching 中的以下代码来解决它:
[self.window addSubview:self.viewController];
到
[self.window setRootViewController:self.viewController];