如何使用故事板将两个不同的Tab栏图标连接到同一个视图控制器? [英] How to connect two different Tab bar icons to same view controller with storyboard?

查看:159
本文介绍了如何使用故事板将两个不同的Tab栏图标连接到同一个视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPad应用中有一个带有6个项目的标签栏控制器。当您点击它们时,其中两个图标将指向相同的视图控制器。此视图控制器有一个它将显示的项目列表,它将根据您点击的标签栏图标略有变化。

I have a tab bar controller in an iPad app with 6 items. Two of the icons will when you tap at them lead to the same view controller. This view controller has a list of items it will show, it will change slightly depending on which of the tab bar icons you tapped.

如何使用故事板进行设置?可以将关系拖动两次到同一个视图控制器,但它只是在选项卡栏上显示两个相同的图标。我希望这两个选择有不同的图标和名称。

How do i set this up with storyboards? Its possible to drag the relationship twice to the same view controller, but then it just shows two of the same icons on the tab bar. I want the two choices to have different icons and name.

推荐答案

就像你找到的那样,你可以在故事板中设计一次视图控制器但是无法将它关联起来使用标签栏控制器不止一次。

Like you've found, you can design the view controller once in the storyboard but won't be able to associate it with the tab bar controller more than once.

您可以做的是在身份检查器中为其分配标识符,然后在运行时您可以使用方法 - [UIStoryboard instantiateViewControllerWithIdentifier :] 实例化视图控制器的第二个副本。您可以使用 - [UITabBarController setViewControllers:animated:]

What you can do is assign an identifier for it in the identity inspector, and then at runtime you can use the method -[UIStoryboard instantiateViewControllerWithIdentifier:] to instantiate a second copy of the view controller. You can insert that second copy into the tab controller using -[UITabBarController setViewControllers:animated:]

这篇关于如何使用故事板将两个不同的Tab栏图标连接到同一个视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆