Maks
Maks

Reputation: 135

MainWindow.xib in Tabbed Application

I am a beginner in IOS field and I find it some what difficult to follow the old tutorials including videos which are not even 4-5 months old. The main reason is that I am working with xcode 4.2.1 and most of the tutorial is based on the earlier versions. So this is sort of letting me down to move with some examples which I want to work out.

The main problem is with MainWindow.xib file, where I found some nice tutorial and video of how one can manually reconstruct MainWindow.xib. I need to say I followed that and was good at recreating it. On the other hand it I have got a question, whatever new project I need to work on other than Empty Application, is it OK to create the MainWindow.xib file in the same way one created for the Empty Application, or it would be different for Tabbed Application or for some other application.

Can somebody throw some light on this!

Thanks Maks

Upvotes: 3

Views: 315

Answers (2)

Nimit Parekh
Nimit Parekh

Reputation: 16864

Following code for the creating the UItabbar. In xcode 4.2.1 there is no any main.xib is created for that u need to apply the dynamically(code) thru create the tabbar and then call it.

-(void)applicationDidFinishLaunching:(UIApplication *)application {

    // Add the tab bar controller's current view as a subview of the window
    tabBarController.delegate=self;
    tabBarController=[[UITabBarController alloc] init];

    mainDashBoard=[[DashBoard alloc] initWithNibName:@"DashBoard" bundle:nil];
    mainSearchView=[[SearchView alloc] initWithNibName:@"SearchView" bundle:nil];
    mainMoreView=[[MoreView alloc] initWithNibName:@"MoreView" bundle:nil];

    UINavigationController *nvCtr0=[[[UINavigationController alloc] init] autorelease];
    UINavigationController *nvCtr1=[[[UINavigationController alloc] initWithRootViewController:mainDashBoard] autorelease];
    UINavigationController *nvCtr2=[[[UINavigationController alloc] initWithRootViewController:mainSearchView] autorelease];
    UINavigationController *nvCtr3=[[[UINavigationController alloc] initWithRootViewController:mainMoreView] autorelease];
    UINavigationController *nvCtr4=[[[UINavigationController alloc] init] autorelease];//[[[UINavigationController alloc] initWithRootViewController:nil] autorelease];

    tabBarController.viewControllers=[NSArray arrayWithObjects:nvCtr0,nvCtr1,nvCtr2,nvCtr3,nvCtr4,nil];

    nvCtr0.tabBarItem.enabled=NO;
    nvCtr4.tabBarItem.enabled=NO;

    [window tabBarController.view];
}

It may be helpful to implement your application

Upvotes: 2

dasdom
dasdom

Reputation: 14063

There are many ways to make an application with a tap bar. I prefer to create the tab bar controller in code and do the interfaces of the view controllers shown in the different tabs with xibs. But sometimes I find it more practical to create the interfaces completely in code.

I would alloc and init a UITabBarController in the AppDelegate and assign the view controllers I need to the tab bar controller. Then you have to assign the rootViewController of the window to the tab bar controller.

Upvotes: 1

Related Questions