3

I have a table view with X number of rows.

One of the row has collection view inside it.

Collection view has Y number of cells.

Every cell has a button.

Now, the problem is; If I apply a tap gesture for button inside the collection view cell it works. But, when I apply a long press gesture to button it is not working at all.

Following is the code that I am trying.

-(void)setupGestureForAllButton{
    for (UIButton *button in self.keyboardButtons) {
        UILongPressGestureRecognizer *gr = [[UILongPressGestureRecognizer alloc] init];
        [gr addTarget:self action:@selector(userLongPressed:)];
        [button addGestureRecognizer:gr];
    }
}
- (void)userLongPressed:(id)sender {
    NSLog(@"user long pressed");
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

Please find the pictorial representation of the problem enter image description here

UPDATE 1 :

setting gr.delegate = self; did the trick.

I am still not sure; then, why it was working for tap gesture in the first place.

Community
  • 1
  • 1
PrafulD
  • 548
  • 5
  • 13

0 Answers0