I know that this has been discussed several times in many other topics, blogs, book, youtube, etc. But, let me explain my case. I want so that when an application opens up, it shows a facebook connect button to login. After the user login, then it will bring up the tabBarView. In my app delegate I first add the MainViewController and there I had shown the facebook connect login button. Then after it's logged in it adds the tabBarViewController as it's sub view.
Now inside this tabBarViewController I want so that it has 2 tabs. The first tab people and second is map. I want to add a navBar in the people tab. So what I did in my code was the following:
tabBarViewController = [[TabBarViewController alloc] init];
mvc = [[MapViewController alloc] init];
UIImage* mapIcon = [UIImage imageNamed:@"13-target.png"];
mvc.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"Map" image:mapIcon tag:0] autorelease];
tvc = [[TableViewController alloc] init];
UIImage* peopleIcon = [UIImage imageNamed:@"112-group.png"];
tvc.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"People" image:peopleIcon tag:0] autorelease];
friendsNavController = [[FriendsNavController alloc] init];
tabBarViewController.viewControllers = [NSArray arrayWithObjects: friendsNavController, tvc, mvc, nil];
tvc.userInfo = _userInfo;
[self.tabBarViewController viewWillAppear:YES];
[self.view addSubview:self.tabBarViewController.view];
The result now is that I have 3 tab bar, one with a nav bar, one with a table list, and one is the map. How can I change the code so that the nav bar and the table view are in one tab bar? What am I doing wrong here?
Here's how it looks on interface builder: