Reputation: 33
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?
Upvotes: 3
Views: 2527
Reputation: 115
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
Upvotes: 3