title: iOS: Warning "attempt to present ViewController whose view is not in the window hierarchy"
body: <p>I am getting following warning when I try to present a ActivityController on navigation controller,</p>
  
  <pre><code>Attempt to present &lt;UIActivityViewController: 0x15be1d60&gt; on &lt;UINavigationController: 0x14608e80&gt; whose view is not in the window hierarchy!
  </code></pre>
  
  <p>I have tried to present view controller by following code,</p>
  
  <pre><code>UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
      activityController.excludedActivityTypes = excludeActivities;
  
      UIViewController *vc = self.view.window.rootViewController;
      [vc presentViewController: activityController animated: YES completion:nil];
  
      [activityController setCompletionHandler:^(NSString *activityType, BOOL completed) {
          NSLog(@"completed");
  
      }];
  </code></pre>
  
  <p>Whats going wrong here ?</p>