16

I have a bar button item in the navigation bar that when pressed, will present a UIAlertController with the style as .ActionSheet. In the iPhone it appears just the way that I want. For the iPad I know I need to add

// For iPad, set the pop over bounds
var popOver = optionMenu.popoverPresentationController
popOver?.sourceView = button as UIView
popOver?.sourceRect = (button as UIView).bounds
popOver?.permittedArrowDirections = UIPopoverArrowDirection.Any

Does anyone know of a way to use the bar button item as the sourceView and the sourceRect? I would like the popover to point to the bar button item.

Mike Walker
  • 2,944
  • 8
  • 30
  • 62

1 Answers1

39

Just use popOver?.barButtonItem = myBarButtonItem

Tapani
  • 3,191
  • 1
  • 25
  • 41