popToRootViewControllerAnimated toolbar not correctly updating
I have a UITabBarController whose tabs are UINavigationController. I have initialized each navigationController by:
iPhoneApp *appDelegate = (iPhoneApp *)[[UIApplication sharedApplication] delegate];
[appDelegate.navigationController2 initWithRootViewController:countryController];
I then drill down the navigationController with:
[self.navigationController pushViewController:myViewController animated:YES];
I want to pop to the root of my navigationController(s) when the user clicks on a tabBar tab.
[delegate.navigationController2 popToRootViewControllerAnimated:NO];
This seems to work great when I only pushViewController one level, but fails when I drill down multiple levels in my navigationController. What happens is that it pops to root but doesn't contain my Root's backbutton or title:
self.navigationItem.title = @"My title";
self.navigationItem.hidesBackButton = YES;
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleDone
target:self
a开发者_高级运维ction:@selector(handleBack:)];
if I don't poptoroot and just use the navigationControlls back button, everything works correctly.
I logged my viewControllers before and after i poptoroot
before: MainCountryController: 0x3d53650, IndividualCountryMfgViewController: 0x3d67d50, IndividualCountryProductViewController: 0x3d60870
after: MainCountryController: 0x3d53650
it's the right view, but wrong toolbar title and backbutton.
Anyone have any ideas? Thanks for your help.
I got this working by disconnecting my navigation controllers from IB an just creating them programatically.
精彩评论