简体   繁体   English

y位置的UITableView内容偏移量始终返回0

[英]UITableView content offset of y position always return 0

In scrollview delegate method table content offset while scrolling always return 0 for it's y position. scrollview委托方法表中,滚动时的内容偏移始终返回y位置的0。

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. 我还打印了myTableView.contentOffset.y但它也打印了相同的结果。

ContentOffset doesn't change when you scrolling. 滚动时ContentOffset不会更改。 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/ 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 尝试跟踪contenView.bounds.origin.y以跟踪y位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM