我如何找到 UITableview 滚动差异 - swift

How do I find UITableview scroll difference - swift

如何找到 UITableView 的滚动差异。 我需要从 swift

中的 tableview 顶部位置找到 Tableview 内容滚动的区别

我尝试了下面的代码,

 func scrollViewDidScroll(_ scrollView: UIScrollView) {
            let contentOffset = tableview.frame.origin.y
            let maximumOffset = (contentOffset - scrollView.contentOffset.y)
            let dif  = maximumOffset
}

Contents offset of tableview, itself describe as difference between top of content to current scroll position.

试试看:

print(tableView.contentOffset)

有关更多信息,请参阅 Apple 文档 - contentOffset

contentOffset : 内容视图原点与滚动视图原点的偏移点。


另请参阅此参考资料:

A UITableViewUIScrollView 的子 class,因此它 具有 contentOffset 属性.

当您了解 class 时,记得检查它的父级 class。有时您要查找的 properties/methods 在父项中。 (我和其他人一样忘记检查父 classes 的接口而感到内疚。)