0

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:

enter image description here enter image description here

enter image description here enter image description here

enter image description here enter image description here

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?

Community
  • 1
  • 1
rattletrap99
  • 1,469
  • 2
  • 17
  • 36
  • maybe you should check that `tappedView.bounds` is the view for `UITableViewRowAction` button – Gerald Jul 17 '16 at 05:53
  • i believe that `tappedView.bounds` is the bounds for the each of your cell. Therefore, the popover can point to anywhere inside the cell. if you are able to find out the bound for each row action, then you can set the `sourceRect` to that bound – Gerald Jul 17 '16 at 06:03
  • But there's the rub, Gerald. There doesn't seem to be any known (or at least well-known) means to understand the hierarchy of a cell using `editActionsForRowAtIndexPath`. I'm still investigating. – rattletrap99 Jul 18 '16 at 23:01
  • perhaps you could use action sheet instead. that seem like a common solution – Gerald Jul 26 '16 at 03:02
  • That would be a possibility. And I may have to do that, my option of choice seemingly impossible to implement. Thanks! – rattletrap99 Jul 27 '16 at 23:26

0 Answers0