I am adding a tabbarcontroller from a uiview controller. Please check my code:
UITabBarController *tabBarController = [[UITabBarController alloc] init];
NSMutableArray *arrControllers = [[NSMutableArray alloc] init];
for(int i = 0; i<arrTabs.count;i++){
NSArray *arr = [arrTabs objectAtIndex:i];
if([[arr objectAtIndex:0] isEqualToString:@"PICS"]){
picTabViewController *pics = [[picTabViewController alloc] initWithNibName:@"picTabViewController" bundle:nil];
UINavigationController *picsNVC = [[UINavigationController alloc] initWithRootViewController:pics];
picsNVC.tabBarItem.image = [UIImage imageNamed:@"tab-news.png"];
picsNVC.tabBarItem.title = [arr objectAtIndex:1];
[arrControllers addObject:picsNVC];
}
if([[arr objectAtIndex:0] isEqualToString:@"MAP"]){
mapTabViewController *maps = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil];
UINavigationController *mapsNVC = [[UINavigationController alloc] initWithRootViewController:maps];
mapsNVC.tabBarItem.image = [UIImage imageNamed:@"tab-news.png"];
mapsNVC.tabBarItem.title = [arr objectAtIndex:1];
[arrControllers addObject:mapsNVC];
}
if([[arr objectAtIndex:0] isEqualToString:@"HTML"]){
htmlTabViewController *html = [[htmlTabViewController alloc] initWithNibName:@"htmlTabViewController" bundle:nil];
UINavigationController *htmlNVC = [[UINavigationController alloc] initWithRootViewController:html];
htmlNVC.tabBarItem.image = [UIImage imageNamed:@"tab-news.png"];
htmlNVC.tabBarItem.title = [arr objectAtIndex:1];
[arrControllers addObject:htmlNVC];
}
}
tabBarController.viewControllers = arrControllers;
self.tabBarController.selectedIndex = 0;
[self.view.window addSubview:tabBarController.view];
The tab bar controller is added as desired. But now I want to add a button to go back to previous page, or you can say remove tabbar and its viewcontrollers from the viewcontroller on which it was added. Can someone please suggest me how can I do it?
Please remember that I have added the tabbarcontroller from viewcontroller and not app delegate.
Regards
Pankaj