Set root view for UINavigationController

怎甘沉沦 提交于 2020-01-23 12:05:08

问题


I seem to have forgotten how to change the root view for a UINavigationController

I have this code:

[window addSubview:navController.view];

but where do i set (preferably through interface builder) the root view please?


回答1:


UINavigationController has a viewControllers property, which is a NSArray and is not read-only, so it can be replaced.

From Apple's UINavigationController reference

Assigning a new array of view controllers to this property is equivalent to calling the setViewControllers:animated: method with the animated parameter set to NO.

So go ahead and create a NSArray with your root view controller and set UINavigationController.viewControllers to that array.




回答2:


See this article :

Changing a UINavigationController’s Root View Controller




回答3:


The subcontroller of your navigation controller is the root controller. You can drag another view controller onto the navigation controller in IB to change it. It's easiest to see if you switch to View -> as List.



来源:https://stackoverflow.com/questions/4204231/set-root-view-for-uinavigationcontroller

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