UISegmentedcontrol to switch views in UITabbarcont

2019-05-22 13:19发布

问题:

I am trying to switch between multiple different views using a UISegmentedControl. I found a really good example to do this in: http://redartisan.com/2010/6/27/uisegmented-control-view-switching-revisited

However, I need to use a UITabbarController in my app. So the navigation controller is not available for me in the app delegate. Is there any other way to switch views in a UITabbarController using UISegmentedControl?

回答1:

First, consider whether you really want to do this. UITabBarController already gives you the ability to switch views, using the tab bar.

If you really want to do this for some reason, UITabBarController has properties viewControllers and selectedViewController that should allow you to do something like what is described in that article.