I used a view-based application and in that I programmatically generate a TabBar. The problem is that:
I have an Iphone application in which I have 2 tabitems using tabbarcontroller. Within the tabbarcontroller, each view controller is a navigation controller. When selecting the second tab, I have a view controller. When choosing a button on this, I click another kind of controller to the self.navigation controller. And in this view manager, I click and I want it like that. But the problem is that I again select the tabitem that the pushedviewcotrooller is shown there. But I need this rootview there again when I select the tab
my code in AppDelegate.m is:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; UINavigationController *nc1; nc1 = [[UINavigationController alloc] init]; UIViewController *viewController1 = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease]; nc1.viewControllers = [NSArray arrayWithObjects:viewController1, nil]; UINavigationController *nc2; nc2 = [[UINavigationController alloc] init]; UIViewController *viewController2 = [[[secondview alloc] initWithNibName:@"secondview" bundle:nil] autorelease]; nc2.viewControllers = [NSArray arrayWithObjects:viewController2, nil]; self.tabBarController = [[[UITabBarController alloc] init] autorelease]; self.tabBarController.viewControllers = [NSArray arrayWithObjects:nc1,nc2,nil]; self.window.rootViewController=self.tabBarController; [self.window makeKeyAndVisible]; return YES; }
source share