Search code examples
iphoneobjective-cipaduitableview

Programmatically 'Touch' UITableViewCell?


I need to programmatically select a UITableViewCell, I have tried this:

NSIndexPath *selectedCellIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
        [table selectRowAtIndexPath:selectedCellIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone];

However, it only selects the cell visually and doesn't pick up on that selection in didSelectRowAtIndexPath unless you actually tap the cell.

Any ideas, has anyone experienced this or have ideas to get around this or approach it differently?


Solution

  • By wanting it pressed, I'm guessing you just want to run the code in didSelectRow?

    Whatever you have in your didSelectRow method, can't you put it in a seperate method of its own and just call it?