TabBarItem 的多个视图控制器
我有一个带有 5 个选项卡的 TabBarController。 “Info”选项卡之一有一个 ViewController(一如既往)。
此 ViewContoller 中的视图有 3 个按钮 - Info1、Info2 和 Info3。 TabController 设置为默认加载“Info1”。 单击这些按钮时,每个按钮都应打开一个新的 ViewController 及其视图。 它不应该是“模态的”,而应该属于 TabBar 控制器(因此 TabBar 是可见的并且可以工作)。 我不想使用导航控制器,因为可以按任何顺序按下按钮。
是否可以: - 更改/替换“信息”选项卡的 ViewController?
我在苹果文档中注意到 TabBarController 的所有视图控制器都可以设置/更改。但有没有办法只改变其中一个呢?
不管怎样:我真的很欣赏 stackoverflow 网站!我发现了大量帮助我开发应用程序的技巧。到处只有好的答案和良好的举止。这是我的第一个问题。谢谢!
I have a TabBarController with 5 Tabs.
One of the Tabs "Info" has a ViewController (as always).
The View in this ViewContoller has 3 buttons - Info1, Info2 and Info3.
The TabController is set to load "Info1" as default.
When clicking these buttons, each should open a new ViewController and it´s View.
It should not be "modal" but should belong to the TabBar Controller (so the TabBar is visible and working).
I do not wan´t a navigation Controller since the buttons could be pressed in any order.
Is it possible to:
- Change/replace a ViewController for the "Info"-tab?
I noticed in Apple dokumentation that ALL Viewcontrollers for a TabBarController could be set/changed. But isn´t there a way to change only one of them?
Anyway: I REALLY appreciate the stackoverflow site! I have found a ton of tips that helped me developing apps. There is only good answers and good manners all over. This is my first question here. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是在界面生成器中进行此操作,然后您只需将视图控制器拖到选项卡栏中,然后它就变成按钮。这真的很容易!
如果您想在应用程序启动时以编程方式实现它,您可以制作 UITabBarItems,并实现 UITabBarDelegate 并监视“tabBar:didSelectItem:”
但是,正如我所说。界面生成器是最简单的!
The easiest would be to make this in interface builder, then you could just drag the view-controllers into the tab bar, then it becomes buttons. It's really easy!
If you would like to make it programaticaly as the app starts up, you could make UITabBarItems, and implement the UITabBarDelegate and watch for "tabBar:didSelectItem:"
But, as i said. Interface builder is the simplest!