(Question in iOS7) I know it is not good to put TabBarController in a NavigationController. But, is there any solution if it's really needed? The stroyboard is like "This".
Here's the problem:
In 'ItemTVC', the backBarItem will not pop to its parent 'SampleTVC', but to root 'ProjTVC', why?
In 'SampleTVC', if called:
[self.navigationController setNavigationBarHidden:NO]
And[self.navigationController.navigationController setNavigationBarHidden:YES]
to hide the root navigation bar and show the nearest ancestor navigation bar, how to set nearest ancestor navigation bar's leftBarButtonItem to backBarButtonItem of the root's navigationItem?If both navigation bar are not hidden, the root navigation bar will dominate (be shown on top of nearest ancestor navigation bar. But, how to add a rightBarButtonItem to the root navigation bar? I tried:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]
andself.navigationItem setRightBarButtonItem:addButton
, but no button is shown.Setting
self.navigationController.backBarButtionItem
never has any effect to its subsequent navigated views. It is always nil.
It seems to me that self.navigationItem
get completed messed up when TabBarController and NavigationController are mixed in this configuration.
(An ugly solution I'm using is: hide the root navigation bar first, then assign a UIBarButtonItem to nearest ancestor navigation bar's leftBarButtonItem, then call [self.navigationController.navigationController popViewControllerAnimated:YES]
,
but this button will be a different style as a 'backBarButtionItem' should be. How to get a copy of the currently displayed backBarButtionItem in a different navigation bar's item?)