0

I'm setting the properties for a UIAlertController like so:

alertController.modalPresentationStyle = .popover
alertController.popoverPresentationController?.sourceView = sourceView
alertController.popoverPresentationController?.sourceRect = sourceView.bounds

Presenting this alertController on an iPad displays a popover as expected, with the tip of the popover arrow in the exact centre of the sourceView, as expected. However, this covers up part of the content of my sourceView. Is there something I can do so that content won't be covered? For example if the arrow is pointing down, the arrow tip will be at the top of my sourceView. And if the arrow is pointing up, the arrow tip will be at the bottom of my sourceView. I could manipulate the sourceRect, but I can't know ahead of time what the arrow direction is going to be.

Ben Williams
  • 4,695
  • 9
  • 47
  • 72

1 Answers1

2

The arrow should be pointing to the outside of the sourceRect relative to the sourceView. When you give sourceView.bounds as the sourceRect that should be the entire source view. So should not overlap.

Set a break point in there and step through and verify everything is as you expect.

trapper
  • 11,716
  • 7
  • 38
  • 82