如何知道tableView开始滚动 [英] How to know that tableView started scrolling

查看:239
本文介绍了如何知道tableView开始滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有疑问:有没有办法拦截 tableView 滚动添加动作?例如,我的原型单元格背景为红色,在单元格内触及其背景颜色开始为蓝色并滚动 tableView 背景颜色返回红色。
是否可以这样做?!

I have a doubt: is there any way to intercept a tableView scrolling to add it an action? For example my prototype cell background is red, touching up inside a cell its background color begin blue and scrolling the tableView background color return red. Is it possible to do this?!

提前致谢。

推荐答案

UITableView 继承自 UIScrollView UITableViewDelegate 扩展 UIScrollViewDelegate

特别是您可能对 scrollViewDidScroll 方法。因此,在 UITableViewDelegate 实现中,添加以下方法:

Particularly you may be interested in scrollViewDidScroll method. So, in your UITableViewDelegate implementation, add the following method:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    NSLog("Table view scroll detected at offset: %f", scrollView.contentOffset.y)
}

这篇关于如何知道tableView开始滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆