Reputation:
- (void) SelectFirstCell
{
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];
}
Hello, i have this very simple method that is supposed to highlight the first Table Cell, but it is not working, the method does get called, and the values do match, Row 0 inSection 0 does exist.
But it does not get highlighted ?
If it makes any difference it is a table created by the Tapku Calendar View
Its worth mentioning that i am very new to Obj C
Upvotes: 1
Views: 124
Reputation: 11276
Try this:
[self.yourTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
Upvotes: 1
Reputation: 2100
you can use this
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[tableView selectRowAtIndexPath:indexPath animated:TRUE scrollPosition:UITableViewScrollPositionNone];
[[tableView delegate] tableView:tableView didSelectRowAtIndexPath:indexPath];
Upvotes: 0
Reputation: 408
Try this:
- (void) SelectFirstCell
{
NSIndexPath * firstElement = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:firstElement];
[self.tableView selectRowAtIndexPath:firstElement animated:NO scrollPosition:UITableViewScrollPositionTop];
}
Hope it help!
Upvotes: 1