title: UIWindow setRootViewController not clearing existing hierarchy
body: <p>In my app I programmatically change root view controllers based on user actions e.g. login/logout functionality.</p>
  
  <p>In iOS 8 - I'm noticing a strange issue. Even after setting rootViewController on the window, the old hierarchy still persists. I just verified it by capturing view hierarchy.</p>
  
  <pre><code>- (void) logout{
       [self.window setRootViewController:[self loadLoginView]];
  }
  
  -(UIViewController *) loadLoginView{
        WelcomeScreenVC *wsVC;
        wsVC = [[WelcomeScreenVC alloc] initWithNibName:@"WelcomeScreenVC" bundle:nil];
        UINavigationController *onboardingVC = [[UINavigationController alloc]initWithRootViewController:wsVC];
        return onboardingVC;
   }
  </code></pre>
  
  <p>Even after executing this line of code, the old logged in view hierarchy still persists. Would appreciate if anybody can suggest what's happening behind the scenes.</p>
  
  <p>Edit: I just looked at UIWindow setRootViewController documentation and here's what Apple has to say about it:</p>
  
  <blockquote>
    <p>The root view controller provides the content view of the window.
    Assigning a view controller to this property (either programmatically
    or using Interface Builder) installs the view controller’s view as the
    content view of the window. If the window has an existing view
    hierarchy, <strong>the old views are removed before the new ones are
    installed.</strong></p>
  </blockquote>