Using a Navigation Controller within Modal Dialogue

Discussion in 'iOS Programming' started by stadidas, Dec 27, 2008.

  1. macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #1
    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:

    Code:
    [[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 :) .
     
  2. thread starter macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #2
    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:

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

Share This Page