I have an UIPopoverController
that presents an UIViewController
using this method:
[self.popover presentPopoverFromBarButtonItem:self.infoBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
self.popover
is my UIPopoverController
.
The code works well, but the Popover arrow is in the middle of the BarButtonItem
how do I display the Popover with its arrow "under" the button?
This is what it currently looks like:
In iOS 9 you can try this code:
let alert = UIAlertController(title: "title", message: "message", preferredStyle: UIAlertControllerStyle.ActionSheet)
alert.modalPresentationStyle = UIModalPresentationStyle.Popover
alert.popoverPresentationController?.barButtonItem = sender
presentViewController(alert, animated: true, completion: nil)
How about this
UIBarButtonItem *item = self.infoBarButtonItem ;
UIView *view = [item valueForKey:@"view"];
if(view){
CGRect frame=view.frame;
[self.popover presentPopoverFromRect:frame
inView:view.superview
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
For all who are using UIViewController
with PopoverPresentationController
(iOS 9+);
This worked for me:
you can directly set your UIBarButtonItem
like this.
myPopoverPresentationController?.barButtonItem = myUIBarButtonItem
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