While investigating a memory leak I discovered a problem related to the technique of calling setRootViewController:
inside a transition animation block:
I try a simple thing which work for me on iOs 9.3 : just remove the old viewController's view from its hierarchy during dismissViewControllerAnimated
completion.
Let's work on X, Y, and Z view as explained by benzado :
That is, this sequence of operations...
- X becomes Root View Controller
- X presents Y, so that Y's view is on screen
- Using transitionWithView: to make Z the new Root View Controller
Which give :
////
//Start point :
let X = UIViewController ()
let Y = UIViewController ()
let Z = UIViewController ()
window.rootViewController = X
X.presentViewController (Y, animated:true, completion: nil)
////
//Transition :
UIView.transitionWithView(window,
duration: 0.25,
options: UIViewAnimationOptions.TransitionFlipFromRight,
animations: { () -> Void in
X.dismissViewControllerAnimated(false, completion: {
X.view.removeFromSuperview()
})
window.rootViewController = Z
},
completion: nil)
In my case, X and Y are well dealloc and their's view are no more in hierarchy !