Y2P
Y2P

Reputation: 111

using dismissModalViewControllerAnimated without deallocating modal view controller

I'm creating an app using the iPhone Utility App framework, and I'm trying to use a navigation controller on the flipside view, as there will be a lot of drilldown options on this view. When I'm done with this view, I call the following code:

- (IBAction)done:(id)sender
{
    [self dismissModalViewControllerAnimated:YES];
}

When I dismiss this view, I want to be able to go back to the place in the navigation I was currently at when I reopen this view again. However, when I dismiss this view using this method, the vc gets deallocated, therefore the menu starts back at the beginning when I try to go back to the menu.

Thoughts?

Upvotes: 0

Views: 316

Answers (3)

cxa
cxa

Reputation: 4248

So what you want is to flip from a view to another view? If you want to keep the navigation bar status between flipping, I recommend you use only one view controller to control this 2 views. you can use + transitionFromView:toView:duration:options:completion: of UIView to flip views.

Upvotes: 0

eric
eric

Reputation: 4951

Hmm not much code so maybe I'm misunderstanding your setup, but...

You could use the AppDelegate to store (as a property) your current position (index) in the views collection of the Navigation controller, and then write a method that pushes to that (stored) position when you re-visit it later.

Might be an easier way to do it though..

Upvotes: 0

Aaron Hayman
Aaron Hayman

Reputation: 8502

You'll need to retain a reference to the object (I'm calling it the options controller). I would say the easiest way is to create an iVar in the presenting view controller that references the options controller. Then, when you go to present the options controller again, just present the referenced options controller rather than creating a new controller. If different view controller objects can present the options controller, you'll need to either pass that reference around, or store it in some object that all the other view controllers have access to.

Upvotes: 2

Related Questions