Andrew Lauer Barinov
Andrew Lauer Barinov

Reputation: 5754

Hiding a Modal View Controller in iOS (but keeping it in memory)

I have a modal view controller activated in my app, and I would like for the user to be able to hide it but retain it's state (navigation stack, etc). According to Apple's docs, dismissModalViewController releases it from memory.

Is there an easy way to retain a reference to it using another method?

Upvotes: 2

Views: 1914

Answers (1)

Bill Burgess
Bill Burgess

Reputation: 14154

Not if you are going to dismiss the view. You might be better off retaining any information about the navigation state and use that to init the new view from other views.

Update I would consider rethinking how you are using a modal view if you need to hide it and display it again. Apple is pretty clear on how and why modals are to be used. There are ways around things, but you could just be going down a path of misery for yourself trying to keep things sorted out.

Apple View Controller Programming Guide (Modal Views)

Upvotes: 2

Related Questions