objective-c – 在iOS6中的单个UIViewController上禁用autorotat
发布时间:2020-12-15 01:59:46 所属栏目:百科 来源:网络整理
导读:我有一个项目使用UINavigationController和segues工作正常,所有这些都正确旋转,事情是…我只是想禁用特定UIViewController上的自动转换。 我试过这个: - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
我有一个项目使用UINavigationController和segues工作正常,所有这些都正确旋转,事情是…我只是想禁用特定UIViewController上的自动转换。
我试过这个: - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return NO; } // New Autorotation support for iOS 6. - (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0){ return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 但是它不起作用,我的UIViewController会自动旋转,任何帮助将被欢迎:) 解决方法
根据视图控制器编程指南
如果要暂时禁用自动旋转,请避免操作方向面罩。相反,覆盖初始视图控制器上的shouldAutorotate方法。在执行任何自动转换之前调用此方法。如果返回NO,则旋转被抑制。 所以你需要子类“UINavigationController”,实现shouldAutorotate并在你的故事板中使用你的导航控制器类。 - (BOOL)shouldAutorotate { id currentViewController = self.topViewController; if ([currentViewController isKindOfClass:[DetailViewController class]]) return NO; return YES; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |