tableview滚动到指定位置

来源:互联网 发布:java大学基础教程 编辑:程序博客网 时间:2024/05/04 19:08

让tableview滚动到特定行

 [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_currentRow inSection:0]

animated:YES

  scrollPosition:UITableViewScrollPositionMiddle];

首先使用selectRowAtIndexes: 选择行数,scrollview滚动到某个position 就计算这个position position = table row height * index,便得到滚动的位置了。

UITableViewCell自动滚动到顶部

[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];

1 0
原创粉丝点击