我在我的应用程序中使用主控制器和详细控制器的自定义分割视图控制器。支持不同视图控制器在iOS 6.0中的不同方向
- (id)initWithMasterController:(UIViewController*)aMasterController
detailedController:(UIViewController*)aDetailedController;
提供给主控制器和细节上的控制器控制器的UINavigationController。
由于我的应用程序的一部分,有两种可能的情况下,进行定向处理:
- 当控制器六个组合在主和细节控制器的使用,所有的方向都支持的应用程序。
- 单独在细节控制器上有一个StudentDetailsViewController时,只能支持两种可能的方向。 (风景)
当过设备的方向发生改变,下面的事情发生版本的iOS以下6.0
的
-shouldAutorotateToInterfaceOrientation:
方法被调用。该方法的实现如下:在运行时,我将请求转发给主控制器,并使用相同的调用将详细控制器转发给控制器。- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { BOOL res = [masterController shouldAutorotateToInterfaceOrientation:interfaceOrientation] && [detailedController shouldAutorotateToInterfaceOrientation:interfaceOrientation]; return res; }
masterController的
-shouldAutorotateToInterfaceOrientation
将返回TRUE。下面是StudentViewController中该方法的实现。- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (IS_IPAD) ? UIInterfaceOrientationIsLandscape(interfaceOrientation) : UIInterfaceOrientationIsPortrait(interfaceOrientation); }
以获得新的定向信息被改变的能力帮我决定是否转动应启用。
与iOS 6.0:
当过设备的方向发生改变,下面的东西的iOS 6.0
版本拆分视图控制器的方法
-shouldAutorotate
发生被调用。它的实施是低于- (BOOL)shouldAutorotate { BOOL res = [masterController shouldAutorotate] && [detailedController shouldAutorotate]; return res; }
的detailedController的shouldAutorotate调用navigationController。自动旋转功能的StudentsController实施:
- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight); }
但与iOS 6.0,我无法控制的方向。尽管supportedInterfaceOrientations方法被调用,但在detailsController的shouldAutorotate方法调用StudentsDetailsController的shouldAutorotate方法时,shouldAutorotateMethod不遵守supportedInterfaceOrientations方法中提到的选项。
UPDATE:
我阅读文档,并在document提供了下面的注解。
有时您可能希望动态禁用自动旋转。例如,对于 示例,如果要在短时间内完全禁止旋转 ,则可以执行此操作。您必须暂时禁用想要手动控制 状态栏位置的 方向更改(例如,当您调用 setStatusBarOrientation:animated:方法时)。
如果要暂时禁用自动旋转,请避免使用 操纵方向遮罩来执行此操作。请改为在最顶端的视图控制器上覆盖shouldAutorotate方法 。在执行任何自动旋转之前调用此方法为 。如果它返回NO,那么将禁止旋转 。
是否可以暂时禁用基于当前方向的自动旋转?
的代码格式无法正确完成.. – Krishnan
你有没有解决这个问题?我有同样的问题,无法弄清楚如何处理这两个ios5和6 – Stas
没有我没有解决它.. – Krishnan