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

development branch: tap recognizer breaks uitableview cell selection in frontview #76

Closed
ekurutepe opened this issue Jan 22, 2013 · 11 comments

Comments

@ekurutepe
Copy link
Contributor

I've inserted a UINavigationViewController with a UITableViewController as the topViewController and saw that the default PKRevealController tap recognizer interferes with the table view selection.

I have a fix that I can submit as a pull request if you wish.

@pkluz
Copy link
Owner

pkluz commented Jan 22, 2013

Mhm I thought I had that tested. Please do submit the request. I can't promise I'll merge it right away but I'll definitely be a great help!

@pkluz
Copy link
Owner

pkluz commented Jan 22, 2013

Did some more testing and have a similar problem with the pan gesture recognizer and a tableview with editable cells (i.e. UIPanGestureRecognizer vs. UISwipeGestureRecognizer). The pan gesture recognizer steals all the touches. Still trying to figure out how Facebook solved the issue in their table view (cell with photo scroll view for instance).

@ekurutepe
Copy link
Contributor Author

The way to achieve that is to create a hierarchy between recognizers by using the requireGestureRecognizerToFail property of the swipe recognizer you're adding. This ensures that your swipe recognizer only starts recognizing after the other has failed.

However since depends so much on the function and structure of the contained view, it might be the best approach to not automatically add the swipe recognizer while setting up the pane controller but to make it available so that the user can customize it and attach it to any desired view.

@pkluz
Copy link
Owner

pkluz commented Jan 23, 2013

You mean not automatically add the pan recognizer to my containers? (Seeing how the swipe recognizer for the tableviewcell's edit modes sits on each tableview…). Fair enough - guess that could be another option key users could pass. I'd have to expose the recognition method but other than that it seems reasonable.

Closed by accident. Reopened.

@pkluz pkluz closed this as completed Jan 23, 2013
@pkluz pkluz reopened this Jan 23, 2013
@ekurutepe
Copy link
Contributor Author

I guess the most flexible solution would be to expose the correctly initialized swipe recognizer as property so that users can attach it to any control as their UI requires (and/or configure recognizer hierarchy). The default setup could stay as it is.

pkluz pushed a commit that referenced this issue Jan 23, 2013
@pkluz
Copy link
Owner

pkluz commented Jan 23, 2013

Did the aforementioned modifications, but I guess it'll be inevitable to have people stumble upon that issue not knowing how to resolve it themselves. Will have to think of something,... - If you have any more ideas, I'm thankful for input :)

@pkluz pkluz closed this as completed Jan 23, 2013
@aaaaahaaaaa
Copy link

There's a very simple and clean way to resolve this problem. PKRevealGesture should implement the Gesture delegate method :
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
In this case, returning YES should resolve all the problems, but you can implement a more specific behavior if you want.

@tfalencar
Copy link

I came to this issue after reading the FAQ and found this to be a better way

Why not just add at the top of gestureRecognizerShouldBegin:

CGPoint touchPosition = [gestureRecognizer locationInView:self.view];
if(!(touchPosition.x < 50.0 || touchPosition.x > self.view.bounds.size.width - 50.0f))
return FALSE;

This solved the problem for me at least! Added the change as pull request..

@vergaramikel
Copy link

Hi, I solved the issue as explained in the FAQ, but I also wanted to have the "show left menu" gesture active. So I did the following:

In the frontViewController: viewDidLoad

//Add a right swipe gesture recognizer
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
                                                                                 action:@selector(showLeftMenu)];
recognizer.delegate = self;
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[self.tableController.tableView addGestureRecognizer:recognizer];

-(void)showLeftMenu{
if (self.revealController.state == PKRevealControllerShowsFrontViewController) {
[self.revealController showViewController:self.revealController.leftViewController];
}
}

Hope you find it useful

@Skornos
Copy link

Skornos commented Mar 4, 2015

@vergaramikel great solution, it is the only one which actually works for me. Did you implement even hideLeftMenu to hide menu on swipe when is revealed?

@Skornos
Copy link

Skornos commented Mar 4, 2015

ok, i'll put my two cents in.

in TableViewController.h add UIGestureRecognizerDelegate
and in TableViewController.m

-(void)viewWillAppear:(BOOL)animated{
self.revealController.revealPanGestureRecognizer.delegate = self;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    if (self.tableView.editing)
        return NO;
    else
        return YES;
}

this way it doesn't interfere with uitableviewcell delete gesture

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

6 participants