xcode 4.2中怎样添加Tab Bar子项目呢?
谢谢各位先
------解决方案--------------------
我给你例子:- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self=[super initWithNibName:nil bundle:nil]) {
//tabBar1
FirstTabBar *tab1 = [[[FirstTabBar alloc] init] autorelease];
tab1.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"FirstTabBar"
image:nil
tag:0] autorelease];
tab1.tabBarItem.image=[UIImage imageNamed:@"icon_map.png"];
UINavigationController *tab1Nav = [[[UINavigationController alloc] init] autorelease];
[tab1Nav pushViewController:tab1 animated:NO];
// TabBar2
SecondTabBar *tab2 = [[[SecondTabBar alloc] init] autorelease];
tab2.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"SecondTabBar"
image:nil
tag:0] autorelease];
tab2.tabBarItem.image=[UIImage imageNamed:@"icon_search.png"];
//TabBar3
ThreeTabBar *tab3 = [[[ThreeTabBar alloc] init] autorelease];
tab3.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"ThreeTabBar"
image:nil
tag:0] autorelease];
tab3.tabBarItem.image=[UIImage imageNamed:@"icon_list.png"];
//TabBar4
FourTabBar *tab4 = [[[FourTabBar alloc] init] autorelease];
tab4.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"FourTabBar"
image:nil
tag:0] autorelease];
tab4.tabBarItem.image=[UIImage imageNamed:@"icon_twitter.png"];
// 组装TabBar
self.viewControllers = [NSArray arrayWithObjects:tab1Nav, tab2,tab3,tab4, nil];
}
return self;
}