Set UIPopover arrow direction and position manually

ios, objective-c, uibarbuttonitem, uipopovercontroller

Solution

Set the direction for the popover using:

[yourPopover setPopoverArrowDirection: UIPopoverArrowDirectionDown];

You can also use `UIPopoverArrowDirectionUp`, `UIPopoverArrowDirectionLeft`, and `UIPopoverArrowDirectionRight`, and `UIPopoverArrowDirectionAny`.

For Swift

yourPopover?.permittedArrowDirections = .up // or .down, .left, .right

Problem

I'm using UIBarButtonItem. In my scenario I want to show a popover from every bar button when I double-click that bar button. So I use a UITapGesture from that UIBarButtonItem. But, the popover arrow always appear in the middle of all UIBarButtonItem. I can't make the arrow appear in the middle of each bar button. My friend was telling me to set the arrow direction using point, but I don't know how to do that. How can I set both the position and direction of the popover's arrow?

Original source