Using UIPopoverPresentationController to present a view controller in a popup, you can define permittedArrowDirections property to restrict the popup positioning possibilities. We can define multiple directions using | operator :
presentationController.permittedArrowDirections = UIPopoverArrowDirectionDown|UIPopoverArrowDirectionUp;
I know that the controller will automatically choose one the those directions, according to available space.
But is it possible to define order priority ? In that way : if there is enough space for both directions A and B, use A in priority.
I've tried to reverse the order of UIPopoverArrowDirectionDown and UIPopoverArrowDirectionUp, but it seems to always prioritize on UIPopoverArrowDirectionDown.
Does anybody has an idea to achieve this ?
I don't think so, the permittedArrowDirections is a OptionSet which is a bitmask under the hood. I would recommend you to some math to calculate is there enough space to display on top and pass in one value based on that.