有时候我们碰到UITableView的内容总是向上偏移一点的问题,可以用下面方式解决。
NSIndexPath* indexPat = [NSIndexPathindexPathForRow:0inSection:0];[self.tableView scrollToRowAtIndexPath:indexPat atScrollPosition:UITableViewScrollPositionBottomanimated:YES];
当然,使用前需要判断数组元素大于0。
下面这两种方式是没有效果的。
[self.tableView scrollRectToVisible:CGRectMake(0,0,1,1) animated:NO];
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
网友评论