0

I am loading my cells from a nib, which are subclasses of UITableViewCell.

Each of these cells are setup with userInteraction set to YES (in the nib file).

When tapping on a cell, the selection of the cell isn't shown (in this case grey) unless the tap is held for a brief moment.

Even when the cell selection style is shown, lifting the finger off the cell still doesn't fire didSelectRowAtIndexPath:.

As mentioned the only way to fire it is to hold down on the cell for about 3 seconds.

Does anyone have any idea why this might be happening? All of the delegates are set up correctly, I also use the dequeuing method of loading cells.

Thanks for any advice and pointers!

EDIT 2

Apologies, misunderstood the deselect methods. Here they are working:

2012-12-28 04:20:28.120 myApp[2022:907] willSelectRowAtIndexPath: <NSIndexPath 0x1cda0400> 2 indexes [0, 0]
2012-12-28 04:20:28.130 myApp[2022:907] didSelectRowAtIndexPath: <NSIndexPath 0x1cda0400> 2 indexes [0, 0]

2012-12-28 04:20:32.166 myApp[2022:907] willSelectRowAtIndexPath: <NSIndexPath 0x1d936630> 2 indexes [1, 0]
2012-12-28 04:20:32.168 myApp[2022:907] willDeselectRowAtIndexPath: <NSIndexPath 0x1cd24770> 2 indexes [0, 0]
2012-12-28 04:20:32.171 myApp[2022:907] didDeselectRowAtIndexPath: <NSIndexPath 0x1cd24770> 2 indexes [0, 0]
2012-12-28 04:20:32.178 myApp[2022:907] didSelectRowAtIndexPath: <NSIndexPath 0x1d936630> 2 indexes [1, 0]

tableView:cellForRowAtIndexPath::

if (indexPath.section == 0) {
    CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"CellID"];

    if (!cell) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
        cell = (CustomCell *)[nib objectAtIndex:0];
    }

    NSArray *data = [[self.indexedData objectForKey:kIndexedDataKey] objectAtIndex:indexPath.row];
    CustomObject *dataObject = [data objectAtIndex:0];

    [cell setDataObject:dataObject];

    return cell;
}

Custom cell properties:

enter image description here

All of the subviews (of the cell) have the same properties:

enter image description here

Adam Carter
  • 4,741
  • 5
  • 42
  • 103

2 Answers2

3

As stupid as I feel, as @NJones said, I had a UITapGestureRecognizer attached to the UITableView. When I remove this, it works fine.

Adam Carter
  • 4,741
  • 5
  • 42
  • 103
0

This topic is a bit old, but I was faced with the same issue:

For me, the problem was because my UITableView was added to an UIScrollView and more specifically to its contentView. It appears that inside the contentView, I had to stay press 2-3 sec to fire the didSelectRowAtIndexPath method.

I moved my TableView to self.view instead of contentView and it solved the problem!

Tib
  • 1,250
  • 13
  • 20