How can i add my UINavigationController and my Tabbar to UIAddressBook

混江龙づ霸主 提交于 2019-12-25 06:46:23

问题


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


回答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




回答2:


[UINavigationController initWithRootViewController], Use for navigation class.

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




回答3:


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


来源:https://stackoverflow.com/questions/4666297/how-can-i-add-my-uinavigationcontroller-and-my-tabbar-to-uiaddressbook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!