3
votes

I was trying to set the presentation of a segue in storyboard to be "Present as popover", and it requires me to add an anchor to it. I have set up a button with code so I could not drag to set the anchor to be that button in storyboard. How can I set the anchor programmatically?

1

1 Answers

3
votes

A UIPopoverPresentationController which creates a popover needs an anchor point either by specifying it to barButtonItem: UIBarButtonItem?, a sourceView: UIView?, or a sourceRect:CGRect.

In your case, you will be applying sourceView: UIView? to the button that you created programatically after initializing your popover...

popover.sourceView = myButton