So how do you correctly setup a popover segue using the storyboard when the button opening it is inside a custom prototype cell within a table view?
- It should work both on iphone and ipad
- It should have the correct position and anchor on ipad
So how do you correctly setup a popover segue using the storyboard when the button opening it is inside a custom prototype cell within a table view?
I think the most elegant solution is the following:
Create a segue from the button as usual to the appropriate ViewController
Open the segue and set the anchor to the table view (dragging from the circle to the view).
In prepare for segue add the following:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIViewController *vc = (UIViewController *)segue.destinationViewController;
UIPopoverPresentationController *ppc = vc.popoverPresentationController;
UIButton *button = (UIButton *)sender;
ppc.sourceRect = button.frame;
ppc.sourceView = button.superview;
}