如何将 UINavigationController 添加到 UITabBar 应用程序的第一个视图?

发布于 2024-10-02 23:17:28 字数 399 浏览 0 评论 0原文

这可能并不完全是您的想法。我有一个 UITabBar 应用程序,带有三个选项卡,所有这些选项卡都链接到单独的 UIView。在第一个 UIView (默认启动视图)上,我有一个搜索表单。此视图没有 UINavigationController (因为此页面上不需要它)。

当用户单击搜索时,我想加载一个具有 UINavigationController 的新视图(并且仍然在底部显示选项卡栏,第一个选项卡仍然突出显示)。

从那里开始,我想像平常一样使用该视图(这超出了这个问题的范围,所以不用担心)。

我该怎么做呢?我看过一些教程,建议将 UITabBar 第一个视图的类从视图控制器更改为导航控制器,但这会将控制器添加到第一个视图(我的搜索表单)的顶部,这不是我想要的: (。

提前感谢 Stack Overflow!

This might not be exactly what you're thinking. I have a UITabBar app, with three tabs, all of which are linked to separate UIViews. On the first UIView (the default launch view) I have a search form. This view does not have a UINavigationController (as it's not wanted on this page).

When the user clicks search, I want to load a new view which has a UINavigationController (and still displays the Tab Bar at the bottom, with the first tab still highlighted).

From there, I want to just utilise the view as I normally would (which is out of the scope of this question so don't worry about that).

How would I go about doing this? I've seen some tutorials that suggest changing the class of the first view of the UITabBar from View Controller to Navigation Controller, but this adds the controller to the top of the first view (my search form) which isn't what I want :(.

Thanks in advance Stack Overflow!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

‘画卷フ 2024-10-09 23:17:28

恐慌结束 - 我找到了一个很好的解决方案:

- (void) viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void) viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}

这隐藏了第一个视图上的 UINavigationController 。

Panic over - I have found a nice solution:

- (void) viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void) viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}

This hides the UINavigationController on the first view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文