Reputation: 147
When the view is load, the tableview will select the first row and it fire the didselectatrow method to do something. I've just know how to select the first row but it not fire the didselectatrow method at a same time Show me how to do like that
Upvotes: 0
Views: 1693
Reputation: 7416
You can just call the method manually in viewDidLoad
:
- (void)viewDidLoad {
[super viewDidLoad];
// select the first row
NSIndexPath *firstRowPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:firstRowPath animated:NO scrollPosition: UITableViewScrollPositionNone];
[self tableView:self.tableView didSelectRowAtIndexPath:firstRowPath];
}
Upvotes: 5