title: Swift: Set UIBarButtonItem as source for popover WITHOUT tap?
body: <p>I want to show a popover on iPad as soon as my view loads having as source a button on the top right corner.
  The popover displays properly on button tap, but I'm having trouble finding a way to display it without the button tap, when the page first loads. Is this possible? </p>
  
  <p>This is what I have:</p>
  
  <pre><code>func displayOptions(sourceButton: UIBarButtonItem)
      let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
      if let popoverController = actionSheet.popoverPresentationController {
          var rect = CGRect(x: 0, y: 0, width: 0, height: 0)              
          popoverController.barButtonItem = sourceButton              
          popoverController.sourceRect = rect 
          popoverController.permittedArrowDirections = .up
      }
      viewController.present(actionSheet, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>This code works properly on button tap, but the app crashes if I try to call this function from viewDidLoad or viewDidAppear:</p>
  
  <blockquote>
    <p>You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.</p>
  </blockquote>