I'm trying to launch a popover from one of several UITableViewRowActions
in a custom UITableviewCell
. It appears that there are no off the shelf delegate methods available to do this in a straightforward way, but my searches turned up the following approaches to the problem:
How to get a reference to button from UITableViewRowAction?
How to correctly start a popover segue from a custom uitableviewcell using the storyboard
How do I implement the UITapGestureRecognizer into my application
Segue from editActionsForRowAtIndexPath
IOS: verify if a point is inside a rect
How to detect a tap gesture in subviews
While each of these was helpful with some aspect of a workaround, none was comprehensive. However, using some guidance from each, I eventually arrived at this code:
else if ([[segue identifier] isEqualToString:@"AccountPopSegue"])
{
UITapGestureRecognizer *tapGestureRecognizer;
CGPoint point = [tapGestureRecognizer locationInView:_thisCustomCell.contentView];
UIView *tappedView = [_thisCustomCell hitTest:point withEvent:nil];
UIViewController *controller = segue.destinationViewController;
controller.popoverPresentationController.delegate = self;
controller.preferredContentSize = CGSizeMake(320, 186);
UIPopoverPresentationController *thisPPC = controller.popoverPresentationController;
thisNavController = (UINavigationController *)segue.destinationViewController;
AccountChangeVC *acCVC = (AccountChangeVC *)thisNavController.topViewController;
acCVC.delegate = self;
thisPPC.sourceRect = tappedView.bounds;
thisPPC.sourceView = tappedView.superview;
}
A tap on the the "Acct" action produces the following behavior, shown for three row cases:
So it appears that I'm close to achieving my desired presentation, but not quite there.
Can anyone suggest changes that will make the popover point directly at the launching UITableViewRowAction
button?