美文网首页
滚动到tableView的指定行

滚动到tableView的指定行

作者: spectatorNan | 来源:发表于2016-04-15 11:58 被阅读1990次

通过选择某行实现:

 [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];

相关文章

网友评论

      本文标题:滚动到tableView的指定行

      本文链接:https://www.haomeiwen.com/subject/sblnlttx.html