Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

Swipe to Delete Broken #123

Closed
awgeorge opened this issue Apr 20, 2013 · 4 comments
Closed

Swipe to Delete Broken #123

awgeorge opened this issue Apr 20, 2013 · 4 comments

Comments

@awgeorge
Copy link

Hello, any chance at looking into using "Swipe to Delete" on a UITableView with this control? At present it doesn't work with the TableView residing inside the frontPanel. This addition would be much appreciated.

@pkluz
Copy link
Owner

pkluz commented Apr 20, 2013

@pkluz pkluz closed this as completed Apr 20, 2013
@awgeorge
Copy link
Author

Damn, i did a search for UITableView Delete in bugs but failed to see the WIKI. Sorry.

I just implemented this function:

  • (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer

as noted in the issue linked on the WIKI page. And all is well.

Any reason you do not wish to add this to the source?

@pkluz
Copy link
Owner

pkluz commented Apr 20, 2013

There's circumstances under which said implementation would cause even weirder behaviour :-)

On Apr 20, 2013, at 7:21 PM, awgeorge notifications@github.com wrote:

Damn, i did a search for UITableView Delete in bugs but failed to see the WIKI. Sorry.

I just implemented this function:

(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
as noted in the issue linked on the WIKI page. And all is well.

Any reason you do not wish to add this to the source?


Reply to this email directly or view it on GitHub.

@awgeorge
Copy link
Author

I completely agree, i experienced these very same issues with simply returning yes, however there is an alternative solution how about this:

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    if([otherGestureRecognizer.view isKindOfClass:[UITableView class]]){
        //Are we a table view?
        if([[(UITableView *)otherGestureRecognizer.view delegate] respondsToSelector:@selector(tableView:canEditRowAtIndexPath:)]){
            //Has the UITableView enabled editing?
            return YES;
        }
    }
    return NO;
}

This checks if the tableview has editing enabled and if so does both actions. It works for me because i only have one panel so i can swipe to the left without both actions triggering.

Perhaps though we can disable the PKReveal panning action automatically if you are swiping a tableview with editing enabled?

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if(touch.view.superview){
        if([touch.view.superview isKindOfClass:[UITableViewCell class]]){
            if([touch.view.superview.superview isKindOfClass:[UITableView class]]){
                if([[(UITableView *)touch.view.superview.superview delegate] respondsToSelector:@selector(tableView:canEditRowAtIndexPath:)]){
                    return NO;
                }
            }
        }
    }

    return YES;
}

This seems to fit the bill, however i can understand that it doesn't look pretty. But i am a novice at objective-c, perhaps a pro can improve this snippet. However the general idea is:

  1. Check whether you have touched a UITableViewCell
  2. Check that the UITableView has editing enabled
  3. Disable the PKReveal Gesture.

Let me know what you think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants