0

I ran into some strange behaviour after I selected a cell using this code :

NSIndexPath * indexPath = [NSIndexPath indexPathForRow:1 inSection:0];

CustomCell * cell = (CustomCell*)[_myTableView cellForRowAtIndexPath:indexPath];

[cell setSelected:YES animated:NO];

After this i couldn't select exactly this cell it just didn't respond and

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath

was never called.

This wasn't called either:

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

What i am doing wrong guys?

Asciiom
  • 9,867
  • 7
  • 38
  • 57
Streetboy
  • 4,351
  • 12
  • 56
  • 101

2 Answers2

0

According to Apple's documentation it is expected behavior that the methods you mention are never called after programmatically selecting a cell. More info is in this post.

Community
  • 1
  • 1
0

You need to call both methods manually because manually cell selection does not call delegate method.

[cell setSelected:YES animated:NO];
[self tableView:_myTableView didSelectRowAtIndexPath:indexPath];
A Amjad
  • 71
  • 3