如何将tabbar控制器显示到下一个View中

时间:2011-12-27 12:03:01

标签: iphone ios

我在AppDelegate中有一个TabBar控制器,然后在TabBar上有一个导航控制器。但是当我将导航控制器推送到其他视图控制器同时保留在TabBar的第一个tabItem上时,我遇到了问题。

我的AppDelegate.h是:

 @interface IlmStreamAppDelegate : NSObject <UIApplicationDelegate,UINavigationControllerDelegate,UINavigationControllerDelegate> 
    {
        UIWindow *window;
        UITabBarController *rootViewController;
        UINavigationController *_navController;
    }

    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet UITabBarController *rootViewController;
    @property (nonatomic, retain) UINavigationController *navController;

    @end

我的AppDelegate.m是:

  #import "IlmStreamAppDelegate.h"

    @implementation IlmStreamAppDelegate

    @synthesize window;
    @synthesize rootViewController;
    @synthesize navController;
    #pragma mark -
    #pragma mark Application lifecycle

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

        // Override point for customization after application launch.

        [rootViewController setTitle:@"Categories"];    
        _navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
        [window  addSubview:_navController.view];

        [self.window makeKeyAndVisible];

        return YES;
    }

    @end

1 个答案:

答案 0 :(得分:0)

您可以编写一个自定义的XXTabBarController(UIViewController的简单子类),可以将其推送到导航控制器堆栈,但仍然具有&#34;查看控制器的所有功能。每个&#34;标签&#34;有自己的视图控制器。