I've been struggling around for some time with this problem. I got it working but not the way it should and I guess its because Im doing it wrong. My goal is to have the following layout.
I have a Main Menu with four buttons. Clicking on each shows a different TableView (I should have a back button in the right corner of the navController, to be able to go back to the main menu, but I don't). Each of these TableViews are inside a UITabBarController (looks like this http://i.stack.imgur.com/GkFwo.jpg)
So how do I have to do this?
This is my current code (definitely wrong at some point(s))
- (IBAction)MyButton:(id)sender
{
self.tabBarController = [[UITabBarController alloc] init];
UIViewController *viewController1, *viewController2, *viewController3, *viewController4;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[[LexikonControllerViewController alloc] initWithNibName:@"LexikonControllerViewController" bundle:nil] setArrays:PflanzenIDs List:ListOfPlants Index:IndexOfPlants dict:DictionaryOfPflantsAndIDs];
}
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
NSArray* controllers = [NSArray arrayWithObjects:navController1, nil];
self.tabBarController.viewControllers = controllers;
CGRect frame = self.tabBarController.view.frame;
frame.size.height = frame.size.height - 20;
self.tabBarController.view.frame = frame;
[self.view addSubview:self.tabBarController.view];
}
EDIT:
Now I tried this:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
vc = [[MyViewController alloc] init];
[vc setTitle:@"Home"];
[vc setParent:self];
navController = [[UINavigationController alloc] initWithRootViewController:vc];
UITabBarController *tb = [[UITabBarController alloc] init];
NSArray *controllers = [[NSArray alloc] initWithArray:[NSArray arrayWithObjects:navController, nil]];
tb.viewControllers = controllers;
[window addSubview:[tb view]];
[window makeKeyAndVisible];
}
Problem: on the main view (with the main menu) I can see the tab bar (which shouldnt be there) and using hidesBottomBarWhenPushed hides the tabbar completetely on all other views :(