I would like to select a cell in a tableView. It is working properly using this code, but once selected programmatically it does not trigger a didSelectRowAtIndexPath
event. How can I trigger it?
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.mainTable selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
It is working as documented:
Calling this method does not cause the delegate to receive a
tableView:willSelectRowAtIndexPath:
ortableView:didSelectRowAtIndexPath:
message, nor will it sendUITableViewSelectionDidChangeNotification
notifications to observers.
Call it yourself after selecting your cell:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self tableView:self.mainTable willSelectRowAtIndexPath:indexPath];
[self.mainTable selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
[self tableView:self.mainTable didSelectRowAtIndexPath:indexPath];
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