Storyboard with NavigationController and TabController

后端 未结 2 1510
南笙
南笙 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).

提交回复
热议问题