两种让tableview返回顶部的方法

1、

 [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_currentRow inSection:0] animated:YES  scrollPosition:UITableViewScrollPositionMiddle];

 首先使用selectRowAtIndexes: 选择行数,滚动的话tableview的superview时scrollview,scrollview可以滚动到某个position 那么就要计算这个position position = table row height * index,就得到滚动的位置了。

UITableViewCell自动滚动到顶部
 
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
 
2、继承自scrollview的方法

[self.tableView setContentOffset:CGPointMake(0,0) animated:YES];

posted @ 2016-06-08 14:13  锦夏ing  阅读(3146)  评论(0编辑  收藏  举报