2

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?

moonvader
  • 19,761
  • 18
  • 67
  • 116
  • Maybe next answer will help you: http://stackoverflow.com/a/29113738/6124910 Good luck! – Patrick May 03 '16 at 08:10
  • So i need to add self.dismissViewControllerAnimated(false, completion: nil) in the beginning if this method? – moonvader May 03 '16 at 08:14
  • how much memory previous vc consumes? Since ios 5 manual memory management replaced with ARC. Check this https://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1 – Behran Kankul May 03 '16 at 08:17

2 Answers2

1

try this,

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

Hope this will help :)

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
0

To avoid jump in animations I use this code:

self.setViewControllers([New_View_Controller_Class()], animated: true)
Ghulam Ali
  • 1,935
  • 14
  • 15