title: UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs on iOS 9
body: <p>I'm trying to show a popup using a custom UIPopoverPresentationController class. But it crashes with the error<code>(&lt;UIPopoverPresentationController: 0x7a772950&gt;) should have a non-nil sourceView or barButtonItem set before the presentation occurs.</code> Below is my button click code where the crash occurs.</p>
  
  <pre><code>- (IBAction)showPopup:(UIButton *)sender {
  ViewController *contentViewController = [[ViewController alloc] init];
  
      contentViewController.preferredContentSize = CGSizeMake(200, 200);
      contentViewController.modalPresentationStyle = UIModalPresentationPopover;
      myPopoverController *popOver = [[myPopoverController alloc]initWithPresentedViewController:contentViewController presentingViewController:self andTintColor:[UIColor lightGrayColor]];
  
      popOver.delegate = self;
      popOver.permittedArrowDirections = UIPopoverArrowDirectionUp;
      popOver.sourceRect = sender.frame;
      popOver.sourceView = self.view;
      [self presentViewController:contentViewController animated: YES completion: nil];
  }
  </code></pre>
  
  <p>Below is a sample of how my custom UIPopoverPresentationController looks like</p>
  
  <pre><code>myPopoverController.h file
  
  @interface myPopoverController : UIPopoverPresentationController
  
  @property (readonly) UIColor *tintColor;
  
  
  -(instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController presentingViewController:(UIViewController *)presentingViewController andTintColor:(UIColor *)aTintColor;
  
  @end
  
  
  myPopoverController.m file
  
  //Some code for UIPopoverBackgroundView
  
  -(instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController presentingViewController:(UIViewController *)presentingViewController
  {
  
      self = [self initWithPresentedViewController:presentedViewController presentingViewController:presentingViewController andTintColor: [UIColor redColor]];
  
      return self;
  }
  
  
  -(instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController presentingViewController:(UIViewController *)presentingViewController andTintColor:(UIColor *)aTintColor
  {
  
      self = [super initWithPresentedViewController:presentedViewController presentingViewController:presentingViewController];
  
      if (!self) {
          return nil;
      }
  
      [super setPopoverBackgroundViewClass: [myPopoverControllerBackgroundView class]];
      tintColor = aTintColor;
  
  
      return self;
  }
  </code></pre>
  
  <p>I don't have a barbutton but I'm setting the sourceView. Am I doing something wrong here? Appreciate your help</p>