我正在开发一个必须在横向和纵向工作的ios应用程序,除了一个视图,应该始终在横向 . 所以我有:
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
如果我以横向模式午餐我的应用程序,并进入此视图并旋转设备(iPad),此方法被调用并返回false,因此界面不会旋转,好东西 .
但如果我是肖像并且进入此视图,则调用此方法并返回false,但方向不会更改 . 在此上下文中,如果我将设备旋转为横向,则该方法返回true并且界面正确旋转,如果我尝试再次旋转为纵向,则此方法返回false并且界面保持在横向中 .
如何在第一次看到此视图时如何实现该功能,如果设备处于纵向状态,界面将更改为横向?
另外,我试过了
- (NSUInteger)supportedInterfaceOrientations
但它永远不会被召唤 .
提前致谢!
1 回答
shouldAutorotateToInterfaceOrientation:
在iOS 6.0中已折旧 . 改为覆盖supportedInterfaceOrientations
和preferredInterfaceOrientationForPresentation
方法 .来自
preferredInterfaceOrientationForPresentation
上的文档