Search code examples
iosuinavigationcontrollerrootview

UINavigationController root view (iOS)


[PersonListNav pushViewController:plist animated:FALSE];Hi there! :) Googling this has returned no luck...

In short, I have UINavigationController (Named PersonListNav) which is instantiated inside of my main xib...

I also have a custom view controller named plist.

I call:

[PersonListNav pushViewController:plist animated:FALSE];

In my app delegate's didFinishLauchingWithOptions method.

It works fine! Except for one thing... There is a back button entitled "Root View Controller". So I thought "Okay, IB must be pushing its own empty view for me, all I need to do is pop that first..."

I tried the following code:

[PersonListNav popViewControllerAnimated:FALSE];
[PersonListNav pushViewController:plist animated:FALSE];

To find that the same exact thing was happening.

As a final test, I tried reversing the two calls!

[PersonListNav pushViewController:plist animated:FALSE];
[PersonListNav popViewControllerAnimated:FALSE];

THAT works as I would expect -- the plist view controller never shows up -- This "Root View Controller" is the currently displayed view.

So, that is my dilemma, it would appear that I cannot pop this Root View Controller off of my stack, to replace it with something else! How would you go about programmatically making plist the root controller?

Thankyou!


Solution

  • In your didFinishLaunchingWithOptions When you init PersonListNav

    Do the following

    //set root view controller to plist controller
    PersonListNav *nav = [PersonListNav initWithRootViewController:plist];
    self.window.rootViewController = nav;