swift - tableview 滚动到指定位置

 

 

滚动一定要在  tableView.reloadData()之后进行

1. 默认  plain 模式

办法1.   tableView.contentOffset.y = 0

办法2  tableView.scrollToRow(at: IndexPath(item: 0, section: 0), at: UITableViewScrollPosition.top, animated: false)

  

2. 分组的 grouped

使用以下两个方法 一起使用, 单独使用一个 也会滚动,但是位置 会在第一个去区头表面
1. tableView.scrollToRow(at: IndexPath(item: 0, section: 0), at: UITableViewScrollPosition.top, animated: false)

2. tableView.contentOffset.y = 0

  

 

 

转载于:https://www.cnblogs.com/qingzZ/p/9698811.html

你可能感兴趣的:(swift - tableview 滚动到指定位置)