Storyboard with NavigationController and TabController

后端 未结 2 1507
南笙
南笙 2021-01-14 18:38

It seems like this should be easy to figure out, but I haven\'t had any luck this afternoon. I threw together this quick, simplified storyboard mockup of my problem.

相关标签:
2条回答
  • 2021-01-14 18:52

    A tab bar controller needs to be the root view controller of your view hierarchy. It goes against the HIG and Apple's standards to put a tab bar controller inside of any other type of container controller.

    From the Apple docs:

    When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

    So, the bottom line here is you need to rethink your design. One option would be to set the UITabBarController as the root view of your window, and then have each of your UITableViewControllers inside of a UINavigationController, which is placed inside of the UITabBarController. In this way, you still get the navigation bar, and stay within Apple's design guidelines (you also won't get those pesky warnings, and Apple may even be throwing an exception nowadays if you try to install a UITabBarController as anything other than the root view of the window).

    0 讨论(0)
  • 2021-01-14 19:00

    I accept JMStone answer but we might get into situation where we need to put tab bar controller inside other controller especially table view controller.

    Please refer Storyboard navigation controller and tab bar controller

    and also the good example by Matthjin: http://cl.ly/VQLa

    Hopes it help some one who want to put tab bar controller inside table view controller and wants proper navigation.

    0 讨论(0)
提交回复
热议问题