How to find the scroll difference of a UITableView. I need to find the difference of the Tableview content scroll from the tableview top position in swift
I tried the below code,
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.
Try this and see:
print(tableView.contentOffset)
For more, see Apple Document - contentOffset
contentOffset : The point at which the origin of the content view is offset from the origin of the scroll view.
Also look at this refernce:
A UITableView
is a subclass of UIScrollView
, so it has a contentOffset property.
When you're learning about a class, remember to check it's parent class. Sometimes the properties/methods you're looking for are in the parent. (I'm as guilty of forgetting to check the interface of parent classes as anybody.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With