Вопрос

My table is relatively simple and not radically different from many I've done before. Yet didSelectRowAtIndexPath is only called on the first 5 cells of the table. After that, the debug statement does not appear when I tap. I've researched this issue here and have ruled out some possibilities that are mentioned in other questions: - the table delegates are properly set. - a GestureRecognizer (that I've set) is not swallowing the presses. - willSelectRowAtIndexPath is not implemented

Below is my didSelectRowAtIndexPath. Let me know what else I can provide that can help solve this problem.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{

    NSLog(@"didSelect");
    NSArray *visibleCells = [partOfSpeechTable visibleCells];
    UITableViewCell *cell = [visibleCells objectAtIndex:indexPath.row];

    NSNumber *checkedState = [checkedStates objectAtIndex:indexPath.row];
    if ([checkedState boolValue]) 
    {
        [cell setAccessoryType:UITableViewCellAccessoryNone];
        [checkedStates setObject:[NSNumber numberWithBool:NO] atIndexedSubscript:indexPath.row];
    }
    else 
    {
        [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
        [checkedStates setObject:[NSNumber numberWithBool:YES] atIndexedSubscript:indexPath.row];
    }

    [[tableView cellForRowAtIndexPath:indexPath] setSelectionStyle:UITableViewCellSelectionStyleNone];
}

(I can comment out all the accessory stuff and it makes no difference).

Thanks for any help.

Это было полезно?

Решение

It turned out that the containing view was shorter than the table itself. The table displayed in full, but the parts below the cut off of the containing view did not respond to user interaction. The solution was to increase the size of the containing view.

Другие советы

I have faced similar kind of issue its probably because of

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{    
        return 20;
} 

set the size of that cell so it can fit in view.

enter image description here

I had the same problem with Jason. In my case, only the cell on the first row wasn't calling didSelectRowAtIndexPath. I increased the containing view of the tableview in xib file (or you could do programmatically).

If didSelectRowAtIndexPath is called only for some cells and the app is running in the simulator then try to reset the simulator.

Menu Hardware > Erase All Content and Settings...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top