tableView scrollToRowAtIndexPath 方法在设置了过大的contentInset的时候会导致计算错误,这边的做法是写个类集成自UITableView,修改其默认实现:
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated {
if(self.useScrollToRowHook) {
CGRect rect = [self rectForRowAtIndexPath:indexPath];
[self setContentOffset:rect.origin];
return;
}
[super scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
}