如何检测UITableView的滚动? [英] How to detect scrolling of UITableView?
问题描述
有一个类似的问题,但答案很笼统,模糊。(检测UITableView滚动 )
请不要解雇。我正在寻找具体的解决方案。
There is a similar question to this but answer is very general, vague.( Detecting UITableView scrolling ) Please don't dismiss. I am looking for concrete solution.
我有 UITableView
它有可编辑的文本字段,当选择了另一个单元格时会出现PickerView。
当用户开始滚动 UITableView
时,我需要隐藏firstResponder或PickerView。
I have UITableView
which has editable textfield and PickerView appears when another cell selected.
What I need is to hide firstResponder or PickerView when user starts scrolling this UITableView
.
到目前为止有问题检测UITableView滚动有一个消息,你应该继承 UITableView
。如果您子类 UITableView
仍然无法访问内部/私有 UIScrollView
。
如何访问 UITableView
的父ScrollView(不违反法律规定)?
So far in question Detecting UITableView scrolling there's a sugestion that you should subclass UITableView
. IF you subsclass UITableView
still internal/private UIScrollView
is not accessible.
How do I access UITableView
's parent ScrollView (without breaking the law)?
谢谢。
推荐答案
您不需要继承 UITableView
来跟踪滚动。您的 UITableViewDelegate 可以作为 UIScrollViewDelegate
。因此,在委托类中,您可以实现 -scrollViewWillBeginDragging:
或任何 UIScrollViewDelegate
方法在你的情况下。 (正如你提到的问题中的实际建议)
You don't need to subclass UITableView
to track scrolling. Your UITableViewDelegate can serve as UIScrollViewDelegate
as well. So in your delegate class you can implement -scrollViewWillBeginDragging:
or whatever UIScrollViewDelegate
method you need in your situation. (as actually suggested in the question you mention)
这篇关于如何检测UITableView的滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!