开发者

How can i add my UINavigationController and my Tabbar to UIAddressBook

I want to use my custom UINavigationContr开发者_JS百科oller and UITabbar for my app it is possible?


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


[UINavigationController initWithRootViewController], Use for navigation class.

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜