如何在tableview中隐藏iPhone工具栏和选项卡栏
我正在开发一个带有两个组件选项卡栏的表格视图应用程序。尽管对于此类应用程序来说似乎很不寻常,但我在选项卡栏上还有一个工具栏,这对于程序的功能来说是一个有用的设置。我在隐藏表格视图的工具栏并显示详细视图时遇到问题。
当用户从表格视图中选择一个单元格时,使用“pushViewController”会正确显示相应的详细信息视图。在与突出显示的选项卡相对应的 rootviewcontroller 中,我使用以下代码使表格视图的工具栏消失:
(void)viewDidDisappear:(BOOL)animated {
toolbar.hidden = YES;
}
当用户返回表格视图时,工具栏将重新出现并使用代码:
(void)viewWillAppear:(BOOL)animated {
toolbar.hidden = NO;
}
在表格视图的每个单元格的详细视图控制器中,我使选项卡使用代码消失(参考):
//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;
}
问题是,用户第一次选择表格视图单元格时,详细视图会正确显示,其自己的工具栏可见,标签栏隐藏,表格视图的工具栏隐藏。使用“后退”按钮返回表格视图后,表格视图的工具栏和选项卡栏会正确显示。但是,对于任何后续单元格选择,当详细信息视图及其工具栏出现时,表格视图的工具栏不再消失,从而导致表格视图的工具栏堆叠在详细信息视图的工具栏上(由于初始表格视图中存在选项卡栏而产生偏移) 。我当然会很感激任何关于为什么这种安排一次有效但随后无效以及如何正确执行的见解。
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 with 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论