title: UIActivityViewController crashing on iPad with sourceView or barButtonItem
body: <p>I have come across what looks like a situation that most people face when trying to present a <code>UIActivityViewController</code> on the iPad; it is crashing with:</p>
  
  <pre><code>Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (&lt;_UIAlertControllerActionSheetRegularPresentationController: 0x7fc4f2d87d00&gt;) should have a non-nil sourceView or barButtonItem set before the presentation occurs.
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>- (void)shareLeaflet
  {
      NSString *forwardedString = [[NSString alloc] initWithFormat:@"Check out this leaflet\n\n %@ \n\nself.theURLToShare];
      UIActivityViewController *activityViewController = nil;
  
      if (IDIOM == IPAD)
      {
          NSLog(@"iPad");
          activityViewController.popoverPresentationController.sourceView = self.view;
  //        activityViewController.popoverPresentationController.sourceRect = self.frame;
          [self presentViewController:activityViewController
                             animated:YES
                           completion:nil];
  
      }
      else
      {
          NSLog(@"iPhone");
          activityViewController = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObjects:forwardedString, nil] applicationActivities:nil];
          [self presentViewController:activityViewController animated:YES completion:nil];
  
  
      }
  </code></pre>
  
  <p>In my <code>viewDidLoad</code>, I have:     </p>
  
  <pre><code>UIBarButtonItem *composeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self                                    action:@selector(shareLeaflet)];
  
      self.navigationItem.rightBarButtonItem = composeButton;
  }
  </code></pre>
  
  <p>This view is a <code>UIPageViewController</code> which is showcasing some images and when the user hits the share button, I'm expecting the iOS 8 style share sheet to popup. This is exactly what happens on the iPhone, but on the iPad, it continues to crash. That led me to Stack Overflow, but none of the questions (<a href="https://stackoverflow.com/questions/33919423/crash-on-showing-uipopoverpresentationcontroller">crash on showing UIPopOverPresentationController</a>, <a href="https://stackoverflow.com/questions/28977348/ios-crash-terminating-app-due-to-uncaught-exception-reason-uipopoverpresentati">iOS Crash: Terminating app due to uncaught exception reason: UIPopoverPresentationController should have a non-nil sourceView</a>, <a href="https://stackoverflow.com/questions/26912903/uiwebviewterminating-app-due-to-uipopoverpresentationcontroller">UIWebViewTerminating app due to UIPopoverPresentationController</a>, <a href="https://stackoverflow.com/questions/25908729/ios8-ipad-uiwebview-crashes-while-displaying-popover-when-user-taps-drop-down-li">ios8 iPad uiwebview crashes while displaying popover when user taps drop down list HTML select tag</a>, etc) work for me. </p>
  
  <p>I have tried all of the solutions in there and I just quite get what is required with this. </p>
  
  <p>This is what I'm trying to achieve:</p>
  
  <p><a href="https://i.stack.imgur.com/uNn7Q.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uNn7Q.png" alt="enter image description here"></a>
  Any thoughts on this would be really appreciated. </p>