2

I'm making a pop over presentation view controller where I need to use multiple arrow directions (up and down). For having multiple permittedArrowDirections I've followed Set Multiple Arrow Directions on UIPopoverController in Swift. Also I tweaked the background color of the pop over so that the arrow blends in with the background dimming view.

The problem is, I need to prefer the UIPopoverArrowDirection.up for almost all cases but for the cases where there is not enough space in right below the source view only then the UIPopoverArrowDirection.down should be used. But I can't find to figure it out. The code snippet is:

let presentationController = .....
presentationController.sourceView = sourceView
presentationController.sourceRect = sourceView.bounds

// changing the array order doesn't help
presentationController.permittedArrowDirections = [.up, .down]

presentationController.backgroundColor = UIColor(white: 0, alpha: 0)
self.present(controller, animated: true)

For making it clear I'm attaching the current output: pop over preferred arrow direction

The source for the demo that I've tried can be found here if anyone needs to follow along.

nayem
  • 7,285
  • 1
  • 33
  • 51
  • You could determine if there is enough room yourself and set the permitted directions to just one value. – rmaddy Jul 01 '19 at 05:34
  • @rmaddy, well. So I need to do manual calculation, right? But other than the height of the popover which measurements should I pay attention to? Can you please point me to the direction? – nayem Jul 02 '19 at 02:19

0 Answers0