下面的帖子是否仍然是检测 UITableView 实例何时滚动到底部 [在 Swift 中] 或它是否已被更改(如:改进)的公认方法?
Problem detecting if UITableView has scrolled to the bottom
谢谢。
最佳答案
试试这个:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let height = scrollView.frame.size.height
let contentYOffset = scrollView.contentOffset.y
let distanceFromBottom = scrollView.contentSize.height - contentYOffset
if distanceFromBottom < height {
print("You reached end of the table")
}
}
或者你可以这样试试:
if tableView.contentOffset.y >= (tableView.contentSize.height - tableView.frame.size.height) {
/// you reached the end of the table
}
关于ios - 检测 UITableView 何时滚动到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39015228/