首页 文章

在视图控制器 - >标签栏控制器 - >导航控制器 - >视图控制器的层次结构内旋转视图控制器

提问于
浏览
0

我的应用程序有一个视图控制器层次结构设置如下:

UIViewController
    |
UITabBarController
    |
    UINavigationController
    |  |
    |  UIViewController (*)
    |
    UINavigationController
       |
       UIViewController (*)

为什么我的UIViewController(*)没有得到(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration方法?

当我的应用程序具有如下设置的视图控制器层次结构时:

UITabBarController
    |
    UINavigationController
    |  |
    |  UIViewController (*)
    |
    UINavigationController
       |
       UIViewController (*)

UIViewController(*)get(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration方法 .

2 回答

  • 3

    这是视图控制器包含问题 . 如果您的目标是iOS 5,则可以使用new UIViewController methods for containment(请参阅管理子视图控制器) . 否则,您需要将旋转消息从根 UIViewController 转发到 UITabBarViewController .

  • 1

    UITabBarController中的所有UIViewControllers都应支持自动旋转,以允许UITabBarController的旋转 . 将此代码放在所有 UIViewController (*) 中:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
       return YES;
    }
    

相关问题