【发布时间】:2019-05-16 09:12:01
【问题描述】:
我正在使用这个函数来检测是否在 tableView 上应用了向上/向下滚动动作。出于某种原因,它只检测向上滚动而不是向下滚动。有任何想法吗?
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
tableView.reloadData()
DispatchQueue.main.async {
if targetContentOffset.pointee.y < scrollView.contentOffset.y {
print("go up")
print(self.currentRow)
self.tableView.scrollToRow(at: NSIndexPath(row: self.currentRow-1, section: 0) as IndexPath, at: UITableView.ScrollPosition.top, animated: true)
} else {
print("go down")
print(self.currentRow)
self.tableView.scrollToRow(at: NSIndexPath(row: self.currentRow+1, section: 0) as IndexPath, at: UITableView.ScrollPosition.top, animated: true)
self.currentRow += 1
}
}
}
【问题讨论】:
标签: ios swift uitableview scroll uiscrollview