Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIButton in cell only gets called on first press #121

Open
mlykke opened this issue Apr 1, 2012 · 3 comments
Open

UIButton in cell only gets called on first press #121

mlykke opened this issue Apr 1, 2012 · 3 comments
Labels

Comments

@mlykke
Copy link

mlykke commented Apr 1, 2012

In each cell in my grid I have added a UIButton but when the button is pressed then both the button action is called as well as the -gridView:didSelectItemAtIndexPath:. In a regular UITableView the actual cell get activated if the press happens on a button.

Also, the button is only called the first time it's pressed: since the cell is also selected and active any of the following presses doesn't get filtered to the UIButton.

@jonsterling
Copy link
Collaborator

Thanks for noticing this bug... We definitely need to fix this so that the cell exhibits the expected behavior. However, it's not exactly the highest priority at the moment, as there are more pressing issues to deal with presently.

In the meanwhile, I'd recommend against embedding buttons in cells from a pure UX standpoint. Typically in iOS interfaces, we want the entire cell itself to perform the action. If your cell requires multiple actions (which is the only use-case I can think of for embedding a button), then you should do this with modes rather than with multiple inputs. For instance, you might have a multiselection mode, a deletion mode, or whatever sort of mode you want, which will determine the action that tapping on the entire cell performs. That's just my two cents.

So, it's a totally legitimate issue, but for now, I'd suggest that you just go with a different design if at all possible. I'm going to leave the issue open, since we do need to fix this at some point.

Thanks so much!
Jon

@dridner
Copy link

dridner commented Aug 16, 2012

This is a bit old, but in order to fix this issue, in the GMGridView.m, add the UIGestureDetectorDelegate method
'(BOOL)gestureRecognizer:shouldReceiveTouch:'

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if([touch.view isKindOfClass:[UIControl class]])
    {
        return NO;
    }
    return YES;
}

This method will work for, not only buttons, but sliders and toggle switches as well, without triggering the gesture detector.

@MarcoTansini
Copy link

thanks dridner, that solves the problem.

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

No branches or pull requests

4 participants