I have a LongPress gesture recognizer initialized in the viewDidLoad method of my viewcontroller as below:
longPressGesture_= [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(displayTimeFlagCallout)];
I have a tableview in my viewcontroller. The tableview has custom cells. Each cell has 2 textfields. I want to bring up a custom popover when a user long presses on the text fields (startTime and endTime). I do not want the magnifying glass and the Copy/Paste popover to show up on long press of textfield as the standard behavior and hence before adding my gesture recognizer, I am disabling the in-built long press gesture recognizer of the text fields. I have added the following code to my cellforRowAtIndexPath method:
MyCustomCell_iPhone *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil)
{
cell = [[MyCustomCell_iPhone alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
for (UIGestureRecognizer *recognizer in cell.startTime.gestureRecognizers) {
if ([recognizer isKindOfClass:[UILongPressGestureRecognizer class]]){
recognizer.enabled = NO;
}
}
for (UIGestureRecognizer *recognizer in cell.endTime.gestureRecognizers) {
if ([recognizer isKindOfClass:[UILongPressGestureRecognizer class]]){
recognizer.enabled = NO;
}
}
[cell.startTime addGestureRecognizer:longPressGesture_];
[cell.endTime addGestureRecognizer:longPressGesture_];
}
However, this is not working. Nothing happens on long press now. Any ideas what could be the issue?
Thanks Hetal