- (void)viewDidLoad {
[super viewDidLoad];
// 预估高度estimatedXXHeight需要置为0,不然会导致定位无准确
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;
NSInteger index = 5;
// [_tableView reloadData];
NSIndexPath *curIndex = [NSIndexPath indexPathForRow:index inSection:0];
[_tableView reloadRowsAtIndexPaths:@[curIndex] withRowAnimation:UITableViewRowAnimationTop];
[_tableView layoutIfNeeded];
// 方式一
[_tableView setContentOffset:CGPointMake(0, SCREEN_HEIGHT*index)];
// 方式二
// [_tableView selectRowAtIndexPath:curIndex animated:NO scrollPosition:UITableViewScrollPositionTop];
// 方式三
// [_tableView scrollToRowAtIndexPath:curIndex atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
示意图: