Question

I have a navigationController app.

I push a tabbar onto the view. Tabs are working title is changed, perfect. Now one of my tabs has a list and I try to link out to a child page within the tabbar:

NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"ProfileDetailController" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES];

Nothing happens. Course this works:

self.view = nextController.view;

I want to be able to push to this subpage within my tabbar AND change the navigationbars buttons. Is this possible?

Was it helpful?

Solution

It sounds like you're pushing a UITabBarController onto a UINavigationController? From Apple's documentation, you can't push a tab bar controller onto a navigation controller.

What you probably want to do is the opposite: have a tab bar controller with UINavigationControllers as the tab items. This is similar to the interface in, say the iPod app or Phone app.

OTHER TIPS

I agree with Alex - a TabBarController inside a navigation controller doesn't seem like a nice UI pattern.

Anyways, to answer your question: Have you tried to access the navigation controller via the tab bar controller?

self.tabBarController.navigationController

I'm not sure if this works, but you could give it a try.

I think I found an easy solution.

In your class where you want to push a view, declare a local UINavigationController as a propterty:

@interface userMenu : UIViewController  {
UINavigationController *navigationController;
}
@property (nonatomic, retain) UINavigationController *navigationController;

Remember to synthesize it.

In your class for the tabBarController:

NSArray *viewControllersArray = [self.tabBarController viewControllers];

userMenu *childUserMenu = (userMenu*) [viewControllersArray objectAtIndex:0];
childUserMenu.navigationController = self.navigationController;

After that you can do [self.navigationController pushViewController:nextController animated:YES];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top