- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
晚上:我有一个 ScrollView ,里面有 3 个 View ..
我对 ScrollView 委托(delegate)有疑问。
didscrolltotop 永远不会被调用,而 did 滚动是...
我不明白原因...
有什么帮助吗?
最佳答案
看起来它只在某些情况下被调用,documentation讨论 scroll-to-top gesture
意味着它可能仅在 轻按状态栏
后起作用,而不是基本滚动。似乎还需要将 scrollsToTop
属性设置为 true
。
The scroll view sends this message when it finishes scrolling to the top of the content. It might call it immediately if the top of the content is already shown. For the scroll-to-top gesture (a tap on the status bar) to be effective, the scrollsToTop property of the UIScrollView must be set to YES.
您还可以使用 contentOffset
func scrollViewDidScroll(_ scrollView: UIScrollView) {
print("The current Y offset is \(scrollView.contentOffset.y)")
if scrollView.contentOffset.y == 0 {
print("we are at the top")
}
}
您可能还想考虑使用 scrollViewDidEndDecelerating
方法,因为这意味着您只会在 ScrollView 稳定下来后收到一个事件。
关于iOS swift : scrollview does not call didscrolltotop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46793858/
晚上:我有一个 ScrollView ,里面有 3 个 View .. 我对 ScrollView 委托(delegate)有疑问。 didscrolltotop 永远不会被调用,而 did 滚动是.
我是一名优秀的程序员,十分优秀!