Here is the problem. I am using the following code in a UINavigationController to replace rootViewController . I need to be able to swap rootViewController between multiple screens and allow the user to switch from each screen (which is obviously why I need a Nav controller):
SomeViewController *tmp = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil]; NSArray * viewControllers = [self viewControllers]; NSArray * newViewControllers = [NSArray arrayWithObjects:tmp, nil]; [self setViewControllers:newViewControllers];
Now, after reading the class reference for the UINavigationController , I saw that for the viewControllers property it says: "the root view controller has index 0 in the array, the reverse lookup controller has index n-2, and the top controller is at index n-1, where n - the number of elements in the array. "
When I print the score of my viewControllers array, I get 1, the current rootViewController. Should there be something there for the top controller (which I assume is a navigation bar)?
As soon as I use setViewControllers with a new view, everything in my navigation bar disappears. I will add that I have a left and right button, as well as a custom name button, which are all initialized and added to the navigation bar in the init method, and work fine until they disappear on me.
Any help would be greatly appreciated.
r0ddy source share