When a UITableView
loads, I want the only row, in the only section, to be selected so that the code in the didSelectRowAtIndexPath
will execute immediately when the user loads the UITableView
. I've tried the code below but it doesn't execute the code in the didSelectRowAtIndexPath
section. Any thoughts?
NSIndexPath *indexedPath = [NSIndexPath indexPathForRow:0 inSection:0];
[tableView selectRowAtIndexPath:indexedPath animated:YES scrollPosition: UITableViewScrollPositionNone];
Make use of this code.This will Automatically call didSelectRowAtIndexPath
when the view is loaded.
[self tableView:tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];