0

I want to use my custom UINavigationController and UITabbar for my app it is possible?

Ali
  • 10,774
  • 10
  • 56
  • 83

3 Answers3

1

Ofcourse it is possible to make custom navigationController with UITabbar.Though i suggest you to take a navigation based application and a Tabbar in it.

You can use the sample code

 NSMutableArray *controllers = [[NSMutableArray alloc] init];


FirstVC *firstController = [[FirstVC alloc] initWithNibName:@"FirstVC" bundle:[NSBundle mainBundle]];

UINavigationController *firstControllerNav = [[UINavigationController alloc] initWithRootViewController:firstController];
firstControllerNav.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:firstControllerNav];

[firstControllerNav release];
[firstController release];



SecondVC *secondController = [[SecondVC alloc] initWithNibName:@"SecondVC" bundle:[NSBundle mainBundle]];

UINavigationController *secondControllerNav = [[UINavigationController alloc] initWithRootViewController: secondController];
secondControllerNav.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:secondControllerNav];
[secondControllerNav release];
[secondController release];

self.tabbar = [[UITabBarController alloc] init];
self.tabbar.viewControllers = controllers;
self.tabbar.customizableViewControllers = controllers;
[self.tabbar setSelectedIndex:0];

[[self.tabbar tabBarItem] setImage:@"image.png"];

Cheers

Aditya
  • 4,414
  • 5
  • 29
  • 40
  • So you want one of the tabs as ABPeoplePickerNavigationControl? – Aditya Jan 12 '11 at 08:43
  • ya let suppose instead of secondController I want to add ABPeoplePickerNavigationController , – Ali Jan 12 '11 at 08:45
  • That can be achieved but by using the modalViewController to present the ABPeoplePickerNavigationController,the tabbar won't be visible. – Aditya Jan 12 '11 at 09:06
  • So ideally what i suggest is keep the ABPeoplePickerNavigationController as a sub item of the main tab. – Aditya Jan 12 '11 at 09:10
  • i mean to say dont keep the Address book directly as a tab as if so you won't be able to view the tabbar,keep it inside the root of any one of the tabs... – Aditya Jan 13 '11 at 04:43
  • Sorry but for this can't provide you code,its an idea,u will have to implement... – Aditya Jan 13 '11 at 05:01
0

[UINavigationController initWithRootViewController], Use for navigation class.

And about UITabbar use like tabbar addItems, [tabbar.items objectAtIndex:X]; X means 0 1 2 3 4 ..

Solid Soft
  • 1,872
  • 2
  • 25
  • 55
0

I found this solution

ColorController * red = [[[ColorController alloc] initWithColor:[UIColor redColor] name:@"Red"] autorelease];
ColorController * green = [[[ColorController alloc] initWithColor:[UIColor greenColor] name:@"Green"] autorelease];
ColorController * blue = [[[ColorController alloc] initWithColor:[UIColor blueColor] name:@"Blue"] autorelease];

UINavigationController * redNav = [[[UINavigationController alloc] initWithRootViewController:red] autorelease];
UINavigationController * greenNav = [[[UINavigationController alloc] initWithRootViewController:green] autorelease];
UINavigationController * blueNav = [[[UINavigationController alloc] initWithRootViewController:blue] autorelease];
ABPeoplePickerNavigationController *picker =[[ABPeoplePickerNavigationController alloc] init];


tabBarController = [[UITabBarController alloc] init];

NSArray * sections = [NSArray arrayWithObjects:redNav, greenNav, blueNav,picker,nil];

[tabBarController setViewControllers:sections];

[window addSubview:[tabBarController view]];
Pang
  • 9,564
  • 146
  • 81
  • 122
Ali
  • 10,774
  • 10
  • 56
  • 83