user7865437
user7865437

Reputation: 812

Programmatically highlight first row in tableview after first load

Im trying to highlight the first row in my table upon first loading the data and just cannot get it to work!

I have tried lots of ways with no joy, the latest attempt being this:

NSUInteger indexArr[] = {0,1};

NSIndexPath *n = [NSIndexPath indexPathWithIndexes:indexArr length:2];

[self.tableView scrollToRowAtIndexPath:n atScrollPosition:UITableViewScrollPositionTop animated:NO];

Upvotes: 0

Views: 1062

Answers (1)

Matthias Bauch
Matthias Bauch

Reputation: 90117

try

[self.tableView selectRowAtIndexPath:n animated:YES scrollPosition:UITableViewScrollPositionTop];

you should probably do this after your view has appeared.

Upvotes: 3

Related Questions