1

Here is my interrogation :

When my app starts a first view controller is loaded, then on top of it a login or signinUp view controller is loaded depending on user choice, then I replace the rootviewcontroller this way :

                    var vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ProposeOrChooseViewController") as ProposeOrChooseViewController
                let window = UIApplication.sharedApplication().windows[0] as UIWindow
                window.rootViewController = vc
                UIView.transitionFromView(
                    window.rootViewController!.view,
                    toView: vc.view,
                    duration: 0.65,
                    options: .TransitionCrossDissolve,
                    completion: {finished in

                        window.rootViewController = vc
                })

Are all the viewcontrollers/views destroyed and removed from the views stack when replacing the rooviewcontroller ?

2 Answers2

0

Yes, my guess is as soon as you lose the reference of your view controller or views, they will get destroyed.

atulkhatri
  • 10,896
  • 3
  • 53
  • 89
0

As long as there is a reference to a controller in your app delegate it will stay around.

I noticed in your code you actually set the root controller before you call transitionFromView? Not sure that looks correct?

There are a number of articles on how to do this scattered around. An issue seems to relate to making it work properly if the device is rotated.

RootViewController animation transition, initial orientation is wrong

This handy function seems to reflect the discussions and it is in swift:

https://gist.github.com/nvkiet/6368d1d45c4ea3e6d9cb

Community
  • 1
  • 1
Rory McKinnel
  • 7,936
  • 2
  • 17
  • 28
  • You were right I deleted the duplicated line where I set the root controller before the `transitionFromView`. And I added `window.rootViewController = nil` before to be sure there is no reference – Hadrien Pierre Mazelier Feb 26 '15 at 11:12