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.
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
.
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)?
Thanks.
UITableView is a subclass of UIScrollView that allows users to scroll the table vertically (the closely-related UICollectionView class allows for horizontal scrolling and complex two-dimensional layouts).
You can add a UITableView to a UIScrollView and have it scroll horizontally.
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)
To expand on Vladimir's answer, this is how I implemented this solution:
In .h file:
@interface MyViewController : UIViewController <UIScrollViewDelegate>
In .m file:
- (void)scrollViewWillBeginDragging:(UIScrollView *)activeScrollView {
//logic here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With