【发布时间】:2011-05-24 20:10:11
【问题描述】:
我遇到了一个让我发疯的问题! 我有一个以 TabBarViewController 开头的 iPad 应用程序。每个 Tab 都有自己的 ViewController 和 nib 文件。
为了使界面方向成为可能,我将所有方向添加到我的 info.plist 并将我的 TabBarController 子类化为设置:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
如果我旋转界面,每个视图都会自动调整大小和格式,以便显示正确的方向。如果我在模拟器中测试它,一切看起来都很好,我可以在方向之间旋转。
现在让我抓狂的是:
如果我在纵向模式下启动应用程序,一切正常。但如果我在横向模式下启动,我会收到错误,我的界面方向似乎仍然是纵向,而模拟器处于横向模式!!
错误:
2011-05-24 21:50:15.011 Project[57995:207] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
我检查了这样的方向:
-(void)viewWillAppear:(BOOL)animated{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight)) {
NSLog(@"Orientation: Landscape");
}
else{
NSLog(@"Orientation: Portrait");
}
}
如果我以横向模式启动,日志显示它处于“横向”模式,但如果我将选项卡更改为另一个选项卡,它看起来很糟糕,因为视图改为以纵向模式显示。 在更改回我要求方向的开始视图时……日志显示“纵向”……但模拟器仍然是横向!
我不明白为什么一开始的方向是纵向的,... 即使我从横向开始......
知道如何解决这个问题吗?
【问题讨论】:
-
info.plist的UISupportedInterfaceOrientations设置是什么? -
我在 info.plist 中添加了 Supported Interface Orientations 的所有项目。第一个是 Portrait(底部主页按钮)
标签: objective-c cocoa-touch xcode ipad orientation