In scrollview
delegate method table content offset while scrolling always return 0 for it's y position.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
print(items:String(format:"Offset %d",scrollView.contentOffset.y))
}
I have also printed the myTableView.contentOffset.y
But it also prints the same result.
ContentOffset
doesn't change when you scrolling. It's origin of your content in scrollView. It defines the point in the content view that is visible at the top left of the scroll view bounds. We can use this property to scroll programmatically .
There is more about it
https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset https://www.objc.io/issues/3-views/scroll-view/
Try to track contenView.bounds.origin.y
for tracking y-position
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.