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

  

上一篇:luogu P2742 【模板】二维凸包 / [USACO5.1]圈奶牛Fencing the Cows


下一篇:CWnd类虚函数的调用时机、缺省实现