Lilz
Lilz

Reputation: 4091

Set root view for UINavigationController

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?

Upvotes: 2

Views: 13932

Answers (3)

defvol
defvol

Reputation: 15480

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.

Upvotes: 8

Ole Begemann
Ole Begemann

Reputation: 135588

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.

Upvotes: 1

Related Questions