如何将我的UINavigationController和我的Tabbar添加到UIAddressBook

时间:2011-01-12 07:31:31

标签: iphone uinavigationcontroller

我想在我的应用程序中使用我的自定义UINavigationController和UITabbar吗?

3 个答案:

答案 0 :(得分:1)

当然可以使用UITabbar制作自定义navigationController。虽然我建议您使用基于导航的应用程序和Tabbar。

您可以使用示例代码

 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"];

干杯

答案 1 :(得分:0)

[UINavigationController initWithRootViewController], 用于导航类。

关于UITabbar使用就像 tabbar addItems, [tabbar.items objectAtIndex:X]; X表示0 1 2 3 4 ..

答案 2 :(得分:0)

我找到了这个解决方案

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]];