分段控制更改时更改视图控制器 [英] Changing view controller when Segmented Control changes
问题描述
这个问题让我发疯。当用户更改分段控件的选定选项卡时,我正在尝试更改 viewController
。我花了几个小时进行研究,但却未能找到一个有效的答案或通过故事板完成的答案。
由于设置标签应用程序非常简单,所以真的很烦我,但尝试使用像标签应用程序这样的分段控件是行不通的。我已经知道如何检测在分段控件中选择了哪个索引。我怎样才能做到这一点?
非常感谢。
我会说这是更改 UIViewController
中的子视图要简单得多,您可以在故事板中设置子视图并使用 IBOulets
连接它们在您的控制器中,您可以将视图的隐藏
属性设置为YES或NO,具体取决于所单击的控件。
现在,如果您使用@Robotic Cat的方法,这也是一个很好的解决方案,您可以在应用程序的工作方式上更加模块化,考虑到您必须使用我提供的解决方案将所有逻辑放在一个控制器中。 / p>
This problem is driving me crazy. I'm trying to change the viewController
when the user changes the selected "tab" of the segmented control. I've spent a couple hours researching and haven't been able to find an answer that works or is done through storyboard.
It really bother me since setting a tab application is so easy, but trying to use the segmented control like the tab application is just not working. I already know how to detect which index is selected in the segmented control. How can I achieve this?
Thank you very much.
I'd say it's much simpler to change subviews within a UIViewController
, you can set up your subviews in your storyboards and hook them up with IBOulets
in your controller you can set the hidden
property of your views to YES or NO depending on the control that was clicked.
Now, if you use @Robotic Cat's approach which is also a good solution you can have a little more modularity in how your app works, considering you'd have to place all your logic in one controller using the solution I presented.
这篇关于分段控制更改时更改视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!