最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[整理]swift中列表中的scrollViewDidScrollToTop的作用和用法

iOS crifan 3755浏览 0评论

折腾:

[已解决]swift中检测列表滚动到顶部

期间,自己发现还有个:scrollViewDidScrollToTop

想要拿来直接去用,结果不行。

所以要去搞懂其含义。

然后自己去写代码,发现有个:

scrollViewDidScrollToTop

    func scrollViewDidScrollToTop(scrollView: UIScrollView) {

去搜:

scrollViewDidScrollToTop

iphone – How can I get scrollViewDidScrollToTop to work in a uiTableView? – Stack Overflow

scrollViewDidScrollToTop 是什么时候出发的? | iOS开发 – CocoaChina CocoaChina_让移动开发更简单

UIScrollViewDelegate Protocol Reference

“- scrollViewDidScrollToTop:

Tells the delegate that the scroll view scrolled to the top of the content.

Declaration

SWIFT

optional func scrollViewDidScrollToTop(_ scrollView: UIScrollView)

OBJECTIVE-C

– (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView

Parameters

scrollView    

The scroll-view object that perform the scrolling operation.

Discussion

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.

IOS UIScrollView常用代理方法 – linux_zkf的专栏 – 博客频道 – CSDN.NET

UIScrollView – scrollViewDidScrollToTop delegate method not firing – Google Groups

[总结]

scrollViewDidScrollToTop不是像字面意思那样,列表滚动到顶部,就可以被调用。

而实际上的滚动到顶部的调用,并不会调用scrollViewDidScrollToTop

而只是:

scrollsToTop设置为true后

并且scrollViewShouldScrollToTop返回true

然后再去点击状态栏,好像视图才回滚动到对应的顶部

才回执行scrollViewDidScrollToTop

大概是这个意思,总之不是我们所想要的。不去继续深究了。

转载请注明:在路上 » [整理]swift中列表中的scrollViewDidScrollToTop的作用和用法

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.193 seconds, using 22.18MB memory