Thursday, 8 November 2012

How to set Tabbar with ViewController..


set tabbarcontroller with viewcontroller like this in `AppDelegate.m` file in `didFinishLaunchingWithOptions:` method for example..

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
           UIViewController *viewController1 = [[[yourViewController1 alloc] initWithNibName:@"yourViewController1" bundle:nil] autorelease];
            UINavigationController *navviewController1=[[UINavigationController alloc]initWithRootViewController:viewController1];

           
            UIViewController *viewController2 = [[[yourViewController2 alloc] initWithNibName:@"yourViewController2" bundle:nil] autorelease];
            UINavigationController *navviewController2=[[UINavigationController alloc]initWithRootViewController:viewController2];

           
            UIViewController *viewController3 = [[[yourViewController3 alloc] initWithNibName:@"yourViewController3" bundle:nil] autorelease];
            UINavigationController *navviewController3=[[UINavigationController alloc]initWithRootViewController:viewController3];

           
            UIViewController *viewController4 = [[[yourViewController4 alloc] initWithNibName:@"yourViewController4" bundle:nil] autorelease];
            UINavigationController *navviewController4=[[UINavigationController alloc]initWithRootViewController:viewController4];

           
            UIViewController *viewController5 = [[[yourViewController5 alloc] initWithNibName:@"yourViewController5" bundle:nil] autorelease];
            UINavigationController *navviewController5=[[UINavigationController alloc]initWithRootViewController:viewController5];

           
            self.tabBarController = [[[UITabBarController alloc] init] autorelease];
            self.tabBarController.viewControllers = [NSArray arrayWithObjects:navviewController1, navviewController2,navviewController3,navviewController4,navviewController5, nil];
        [self.window makeKeyAndVisible];
        return YES;
    }

No comments:

Post a Comment