TabBar控制器和导航控制器App ios7中的支持方向

时间:2014-04-28 08:16:20

标签: ios objective-c screen-orientation

您好我有一个 tabBarController ,其中包含4个标签,每个标签都有自己的导航控制器,是否可以仅在某些<中进行旋转强> viewControllers

我在AppDelegate上使用这样的方法

- (NSUInteger)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    if ([[self.window.rootViewController presentedViewController]
         isKindOfClass:[ChatController class]]) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    } else {

        if ([[self.window.rootViewController presentedViewController]
             isKindOfClass:[UINavigationController class]]) {

            // look for it inside UINavigationController
            UINavigationController *nc = (UINavigationController *)[self.window.rootViewController presentedViewController];

            // is at the top?
            if ([nc.topViewController isKindOfClass:[ChatController class]]) {
                return UIInterfaceOrientationMaskAllButUpsideDown;

                // or it's presented from the top?
            } else if ([[nc.topViewController presentedViewController]
                        isKindOfClass:[ChatController class]]) {
                return UIInterfaceOrientationMaskAllButUpsideDown;
            }

            UITabBarController *tb = (UITabBarController *)[self.window.rootViewController presentedViewController];
            if ([tb.tabBarController isKindOfClass:[ChatController class]]) {
                return UIInterfaceOrientationMaskAllButUpsideDown;

                // or it's presented from the top?
            } else if ([[tb.tabBarController presentedViewController]
                        isKindOfClass:[ChatController class]]) {
                return UIInterfaceOrientationMaskAllButUpsideDown;
            }
        }
    }

    return UIInterfaceOrientationMaskPortrait;
}

也许 TabBarController 并不好 或者有任何方法 请告诉我

先谢谢

0 个答案:

没有答案
相关问题