Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionSheet Source View BarButtonItem

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.

like image 379
Mike Walker Avatar asked Apr 29 '15 16:04

Mike Walker


1 Answers

Just use popOver?.barButtonItem = myBarButtonItem

like image 81
Tapani Avatar answered Nov 14 '22 19:11

Tapani