首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >选择新选项卡时,iOS UITabBarController不AutoRotate

选择新选项卡时,iOS UITabBarController不AutoRotate
EN

Stack Overflow用户
提问于 2012-08-10 06:04:49
回答 5查看 2.9K关注 0票数 1

我有一个基于UITabBar的iOS应用程序,有5个标签,其中一些是UINavigationController。我的一些标签视图支持风景,而另一些则不支持。

我已经处理了视图本身的所有自动旋转,但我注意到在测试应用程序时发生了一些奇怪的事情-每当选择一个新选项卡时,任何UIViewController都不会调用shouldAutoRotateToInterfaceOrientation方法。有没有办法在选择新选项卡时强制进行方向检查?

EN

回答 5

Stack Overflow用户

发布于 2012-08-10 07:12:27

创建一个方法并在viewWillAppear中调用它来检查方向,然后在需要时强制它。

票数 1
EN

Stack Overflow用户

发布于 2012-08-10 08:36:05

通常,当我看到这种情况时,是因为选项卡栏中的某个视图控制器没有正确设置shouldAutoRotateToInterfaceOrientation。添加到选项卡栏中的所有类都需要设置相同的值,否则会导致循环出错。

票数 0
EN

Stack Overflow用户

发布于 2012-08-14 20:59:40

方法shouldAutorotateToInterfaceOrientation:NOT supported in iOS 6。它已被弃用。如果你是一个新手,刚刚开始使用可可,并且想知道为什么你的视图控制器在iOS 6中搞砸了,而在iOS 5中却是完美的,只要知道shouldAutorotateToInterfaceOrientation:不再被支持就行了。即使它可以与Xcode 4 to 4.3很好地协同工作,它也将NOT work on Xcode 4.5.

苹果提供了一种新的方法,以一种更干净的方式完成这件事。您可以改用supportedInterfaceOrientations。它返回视图控制器支持的所有接口方向,即接口方向值的掩码。

UIInterfaceOrientationMask Enum:

这些常量是用于指定视图控制器支持的接口方向的掩码位。

代码语言:javascript
复制
    typedef enum {
     UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait),
     UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft),
     UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight),
     UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown),
     UIInterfaceOrientationMaskLandscape =
     (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
     UIInterfaceOrientationMaskAll =
     (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
     UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
     UIInterfaceOrientationMaskAllButUpsideDown =
     (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
     UIInterfaceOrientationMaskLandscapeRight),
 } UIInterfaceOrientationMask;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11892653

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档