如何在tableview中隐藏iPhone工具栏和选项卡栏

发布于 2024-10-01 10:44:16 字数 1096 浏览 2 评论 0原文

我正在开发一个带有两个组件选项卡栏的表格视图应用程序。尽管对于此类应用程序来说似乎很不寻常,但我在选项卡栏上还有一个工具栏,这对于程序的功能来说是一个有用的设置。我在隐藏表格视图的工具栏并显示详细视图时遇到问题。

当用户从表格视图中选择一个单元格时,使用“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文