How to hide iPhone toolbar combined with tab bar in tableview
I am developing a tableview application with a two-component tab bar. Although it seems unusual for this sort of application, I also have a toolbar over the tab bar, which is a useful setup for the program's functionality. I am having a problem with hiding the tableview's toolbar with displaying a detail view.
When the user selects a cell from the tableview, the corresponding detail view appears properly using "pushViewController." In the rootviewcontroller corresponding to the highlighted tab, I make the tableview's toolbar disappear using the code:
(void)viewDidDisappear:(BOOL)animated {
toolbar.hidden = YES;
}
When the user returns to the tableview, the toolbar reappears wit开发者_StackOverflow中文版h the code:
(void)viewWillAppear:(BOOL)animated {
toolbar.hidden = NO;
}
In the detail view controller for each cell of the tableview, I make the tab bar disappear using the code (with reference):
//http://stackoverflow.com/questions/1627930/hide-the-tab-bar-when-pushing-a-view
(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
self.hidesBottomBarWhenPushed = YES;
return self;
}
The problem is that the first time the user chooses a tableview cell, the detail view appears properly with its own toolbar visible, and with the tab bar hidden and with the tableview's toolbar hidden. The tableview's toolbar and tab bar appear properly upon returning the to tableview with the "back" button. However, with any subsequent cell selection, the tableview's toolbar no longer disappears when the detail view appears with its toolbar, resulting in the tableview's toolbar stacked over the detail view's toolbar (offset because of the presence of the tab bar in the initial table view). I certainly would appreciate any insight as to why this arrangement works once, but not subsequently, and how to do it properly.
精彩评论