Dumb question - but how do I present an UIAlertController (popover) from a toolbar button? Previously (with UIAlertView) I'd simply call showFromBarButtonItem: but this doesn't appear to be possible with the UIAlertController.
I have a workaround - as below - but it's a bit 'risky'
UIView* senderView = [sender valueForKey:@"view"]; //HACK
UIPopoverPresentationController* popover = alertController.popoverPresentationController;
if (popover)
{
popover.sourceView = senderView;
popover.sourceRect = senderView.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
(sender is a UIBarButtonItem)
Try to setpopover.barButtonItem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With