简体   繁体   中英

how to show tabbar controller into next View

I have a TabBar Controller in AppDelegate and then Navigation Controller on TabBar. But i get problem when i push Navigation Controller to other View Controller while remaining on first tabItem of TabBar.

My AppDelegate.h is:

 @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

My AppDelegate.m is:

  #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

您可以编写一个自定义XXTabBarController(UIViewController的普通子类),可以将其推入导航控制器堆栈,但仍具有“视图控制器”的所有功能。每个“选项卡”都有其自己的视图控制器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM