I am developing one application which includes view controller because my first two pages content only view not tab-bar.after that i have created run time tab-bar controller using this code
UIViewController *viewcontroller1 = [[viewcontroller1 alloc] initWithNibName:@"viewcontroller1" bundle:nil];
viewcontroller1.title = @"sometext";
viewcontroller1.tabBarItem.image = [UIImage imageNamed:@"someimage.png"];
UIViewController *viewcontroller2 = [[viewcontroller2 alloc] initWithNibName:@"viewcontroller2"开发者_JS百科 bundle:nil];
viewcontroller2.title = @"sometext";
viewcontroller2.tabBarItem.image = [UIImage imageNamed:@"someimage.png"];
tbc = [[UITabBarController alloc] initWithNibName:@"viewcontroller1" bundle:nil];
tbc.viewControllers = [NSArray arrayWithObjects: viewcontroller1,viewcontroller2, nil];
tbc.selectedViewController = viewcontroller1;
//// NSLog(@"Selected index = %d of %d", tbc.selectedIndex, [tbc.viewControllers count]);
[self presentModalViewController:tbc animated:NO];
it is working properly but in my second view i want tab-bar controller and navigation-controller both. so in viewcontroller2 i have implemented code like that it's giving me navigation controller but it's hiding tab-bar controller
- (void)viewDidLoad
{
nvc = [[UINavigationController alloc] initWithRootViewController:[[viewcontroller2 alloc] initWithNibName:@"viewcontroller2" bundle:nil]];
[self presentModalViewController:nvc animated:NO];
[nvc release];
[super viewDidLoad];
}
so please help me what to i do so i can get both tab-bar controller & navigation-controller in this viewcontroller2.?? please guide me.
You can create new class for tabbar and in UI Design time you can add navigation controller as tab and set view in navigation controller. Whenever you want add tabbar controller in that page create object of tabbarcontroller class object and add it on view.
精彩评论