UINavgationController 和 UITabBarController 在一起

发布于 2024-10-23 20:18:35 字数 516 浏览 6 评论 0原文

我正在尝试创建一个视图,其中 TableView 位于中心,NavigationBar 位于顶部,TabBar 包含 5 个项目。 TabBarItems 将附加到 5 个不同的模式视图。表格视图可以选择一个项目并“导航”到另一个表格视图或详细信息视图。

按照Apple文档,我尝试在IB的TabBarController中创建NavigationController,但失败了。我阅读了与此主题相关的所有帖子,它们都在 TabBarItem 之一中描述了 NavigationController。但这不是我想要的。 TabBarController 和 NavigationController 是单独的控制器,在同一视图中执行单独的操作。

所以我开始怀疑这可能是一个设计问题。我应该只使用 NavigationController 并将 TabBar 添加为对象而不是视图中的控制器。

我是否走在正确的轨道上,或者是否有更好的方法在 IB 中结合 NavigationController 和 TabBarController 来完成我想要的工作。我说得有道理吗?

I am trying to create a view with a TableView in the center, NavigationBar on top, and a TabBar with 5 items. The TabBarItems will be attached to 5 different modal views. And the tableview can select an item and "navigate" to another tableview or detail view.

Following the Apple doc, I tried to create a NavigationController in a TabBarController in IB, but failed. I read all the posting regarding to this topic, and they all described a NavigationController inside one of the TabBarItem. But that is not what I want. The TabBarController and NavigationController are separate controller doing separate thing in the same view.

So I start wondering maybe it is a design issue. I should just use a NavigationController and add the TabBar as objects and not controller in the view.

Am I going the right track or is there a better way to combine NavigationController and TabBarController in IB to do the job that I want. Am I making sense?

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

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

发布评论

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

评论(1

原谅过去的我 2024-10-30 20:18:35

如果标签栏实际上用作标签栏,听起来您需要 5 个导航控制器,每个标签一个。

如果选项卡栏用作工具栏来容纳调出模式视图控制器的按钮、将视图推送到导航控制器或除选项卡栏用途之外的其他操作,请改用 UIToolbar。 UINavigationController 实际上内置了工具栏支持,只需将其 toolbarHidden 属性设置为 NO,并将每个可以进入导航控制器内部的视图控制器上的 toolbarItems 属性设置为适当的数组UIBarButtonItems。

If the tab bar is actually being used as a tab bar, it sounds like you want 5 navigation controllers, one for each tab.

If the tab bar is being used as a toolbar to hold buttons that bring up modal view controllers, push views onto the navigation controller, or other actions besides what a tab bar is intended for, use a UIToolbar instead. UINavigationController actually has toolbar support built in, just set its toolbarHidden property to NO and set the toolbarItems property on each view controller that can go inside the navigation controller to an array of appropriate UIBarButtonItems.

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