I have taken a project based on the standard iPad SplitViewerController template and implemented recursive drill down navigation to any number of levels as follows:
Firstly I created a new view controller (named NavItemController) which I pop onto the controller stack in the didSelectRowAtIndexPath method of the RootViewController as follows:
NavItemController *navItemController = [[NavItemController alloc] initWithNibName:@"NavItemController" bundle:[NSBundle mainBundle]];
navItemController.title = catalogue.name;
[[self navigationController] pushViewController:navItemController animated:YES];
I then use this view controller for all navigation up and down my tree structure (so the RootViewController is now only used to show the initial root level of navigation i.e. items with no parent).
That all works nicely.
Now I am trying to update the label on the detail view (detailViewDescriptionLabel) when I select an item in the NavItemController. To do this I first added an outlet to my NavItemController:
@property (nonatomic, strong) IBOutlet DetailViewController *detailViewController;
and configured it in InterfaceBuilder by adding a view controller from the library to the Objects list, changing its class to DetailViewController and hooking up the the outlet that I found under File’s Owner.
At this point if I step through my code I find that it correctly sets the detailItem in my detail view to the object selected in my NavController – and it seems to correctly set the detailDescriptionLabel.text value to a value from this detailItem. However this is not reflected in the UI (it does still work if I do this from the RootViewController).
I’m guessing that I have not hooked something up correctly or missed a step somewhere – I am (obviously) pretty new to iOS – any pointers would be appreciated.
I ended up resolving my problem by creating my project from scratch using iOS 5 and the Master Detail template. I also selected to use the storyboarding feature.
I was able to use the MasterViewController (same as RootViewController in earlier template) for my recursive navigation i.e. I did not need to create a separate view controller.
The code in the MasterViewController didSelectRowAtIndexPath method ended up being:
Also important is the viewWillDisappear method in the MasterViewController: