View Full Version : Using a Navigation Controller within Modal Dialogue

Dec 27, 2008, 07:08 PM
Hi guys,

I am trying to achieve something very similar to part of the user interface of the Calendar application on the iPhone. When the calendar is being viewed, there is a + icon on the right bar button on the navigation bar. Pressing this raises a modal dialogue, which has it's own navigation controller, so when a calendar detail is edited, the editing view can slide into view.

Currently, I am raising a modal dialogue like this:

[[self navigationController] presentModalViewController:newTransactionViewController animated:YES];

This works perfectly well. However, it is just a plain view controller being loaded in. What I would like to do is load in a view controller that is the child of a UINavigationController, so that I may then push and pop views while in the modal dialogue state. I have created a xib containing a UINavigationController with it's root controller set to one of my UIViewController subclasses, but I do not know how to use this xib with a modal dialogue.

As always any help will be much appreciated :) .

Dec 28, 2008, 09:23 AM
Never mind, I solved this myself. Once I remembered that UINavigationController was a subclass of UIViewController (it had been a long night) I simply did this:

UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:newTransactionViewController];
[[self navigationController] presentModalViewController:controller animated:YES];