Discussion in 'iOS Programming' started by ayh, Sep 12, 2009.

  1. ayh macrumors newbie

    Sep 12, 2009
    I have a bunch a views connected through buttons by using the command presentModalView

    For example they're connected like this: View1 -> View2 -> View3 -> View4

    In View4 I want to make a button that goes back to View1. I figured out how to do this by writing this:

    [self.parentViewController.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];

    However once I go back to View1 I can't click through again like how I was able to before I dismissed it (I get stuck at View2 because the buttons don't click anymore).

    I found this in the SDK documentation:

    "If you dismiss a modal view controller in the middle or bottom of the stack, all the modal view controllers on top of that view controller are also dismissed. Use the modalViewController property before invoking this method if you need to retain the modal view controller."

    I think this is the problem I'm running into, but I don't really know what they mean by using the modalViewController property. I'd appreciate any tips.
  2. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    have you tried dismissing them one at a time from the order in which they appeared? something like:

    [view4 dismissModelViewControllerAnimated:NO];
    [view3 dismissModelViewControllerAnimated:NO];
    [view2 dismissModelViewControllerAnimated:NO];
    while my suggestion is ghetto, if you're using a navigation controller the "proper" way is to use popToRootViewControllerAnimated:, or popToViewController:animated: and choose which view you want to goto.

Share This Page