moonvader
moonvader

Reputation: 21091

Clear memory when new ViewController is presented

I have some buttons in my app interface that act like this

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextVC = storyBoard.instantiateViewControllerWithIdentifier("customVC") as! customVC
self.presentViewController(nextVC, animated:true, completion:nil)

When user presses them - the new ViewController is shown and everything is ok except one thing - I think that previous ViewController is still in memory. How can i clear it?

Upvotes: 2

Views: 713

Answers (2)

Ghulam Ali
Ghulam Ali

Reputation: 1935

To avoid jump in animations I use this code:

self.setViewControllers([New_View_Controller_Class()], animated: true)

Upvotes: 0

Ketan Parmar
Ketan Parmar

Reputation: 27438

try this,

  self.presentViewController(vc, animated: true, completion: {() -> Void in
        self.dismissViewControllerAnimated(false, completion: { _ in })

Hope this will help :)

Upvotes: 1

Related Questions