I was wondering is there a way that I could have my code "tap" a cell in my UITableView in order to reproduce the behaviour specified in the - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
delegate method.
I guess in other words, is is possible to invoke the - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
delegate method programatically?
if you want to have the cell selected, i.e highlight a specific cell:
//select first row of first section NSIndexPath* selectedCellIndexPath= [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView selectRowAtIndexPath:selectedCellIndexPath animated:false scrollPosition:UITableViewScrollPositionMiddle];
if you want to additionally trigger actions in your didSelectRowAtIndexPath method, you need to manually call the delegate method, it won't happen automatically:
[self tableView:self.tableView didSelectRowAtIndexPath:selectedCellIndexPath];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With