user1459524
user1459524

Reputation: 3603

How to unload UIViewcontroller from memory?

My app structure (targeting iOS 6.1 w/ARC):

Intro View Controller ->presents-> Main Menu View Controller ->presents-> Stuff View Controller

The Intro View Controller is shown only once, on app launch. The user is able to jump back to the Main Menu View Controller (currently achieved by using dismissViewControllerAnimated:).

But how do I get rid of the Intro View Controller still lingering in memory?

Upvotes: 0

Views: 583

Answers (3)

rdelmar
rdelmar

Reputation: 104082

You should use a different structure to do this. Make MainMenuViewController the root view controller of the window, and present IntroViewController modally from MainMenuViewController's viewDidAppear method with no animation. This will make IntroViewController the first thing the user sees. Dismiss it when you're done with it, and it will be deallocated.

Upvotes: 2

Khanh Nguyen
Khanh Nguyen

Reputation: 11134

Use UINavigationController's setViewControllers: to manually alter the view controller stack after the launch view controller disappeared.

Upvotes: 1

Mick MacCallum
Mick MacCallum

Reputation: 130183

Why not configure your hierarchy so that when it is necessary to present intro view controller, it gets presented from main menu view controller without any animation so that it appears to have been the first view controller you interact with.

Then you can dismiss it to get back to main menu view controller thus freeing it from memory. From here you can present stuff view controller as you normally would.

Upvotes: 0

Related Questions