Can a UISplitViewController be the root controller in a UINavigationController?

和自甴很熟 提交于 2019-12-10 23:15:56

问题


Interface builder does not allow you to add a UISplitViewController as the root controller of a UINavigationController. I've also tried programmatically creating the UINavigationController and setting its root view controller to be the UISplitViewController.

The result is an empty window with just the nav bar.

I've also tried a split view controller replacement, MGSplitViewController. It mostly works, except that within the split view controller, the master view is another UINavigationController. Its nav bar shows up too thick. Changing orientation and back clears it up.

I've been trying all sorts of different approaches to having a view that looks like a split view and other views that I switch between. I've tried within a tab view controller, writing my own controller to manage subviews of the window and having the split view as a managed view, and now the navigation controller. All attempts have had some issues. The most consistent issue is regarding the orientation of the view. My app is running in landscape mode and typically the child views think its still portrait.

Any ideas appreciated.


回答1:


No.

The bottom line: a UISplitViewController must be the root view of an app (or perhaps more specifically, a window). It can not live inside a UINavigationController or anything else.

This is the case with the current SDK, and there's no guarantee that will change in future SDKs.




回答2:


It seems strange to add a split view to a navigation stack. The master pane of a split view controller is generally a navigation controller, so (without knowing more about your design), I'd probably use that to control your navigation hierarchy.



来源:https://stackoverflow.com/questions/3723342/can-a-uisplitviewcontroller-be-the-root-controller-in-a-uinavigationcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!