Basically what I want to achieve is having a UITextField inside a custom UITableViewCell while this textfield should only triggers on long press. So if the user just taps once on the textfield, the cell should triggers its delegate method didSelectRow.
So far I added a long press on my textfield and removed all others gestures. So my textfield correctly triggers when I'm long pressing it. But the problem is that when I'm just tapping on the textfield, the cell doesn't get triggered and the didSelectRow method doesn't get called. If I tap outside of my textfield, the method is correctly called ofc.
Here is my code :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.nameTextField.gestureRecognizers = nil;
UILongPressGestureRecognizer *longPressTextField = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleCellTextFieldLongPress:)];
[cell.nameTextField addGestureRecognizer:longPressTextField];
return cell;
}
I tried different things with the UIGestureRecognizerDelegate but none seemed to work :(.
Any ideas appreciated ! Thx !