How to detect a drag event of a UITableView?

I need to be notified when the resistance UITableViewcomes to an end.

But I am working on the UITableView category, so I cannot use this scrollViewDidEndDragging:willDecelerate:for archiving.

I tried using KVO to observe on draggingthe Key Path:

[self addObserver:self forKeyPath:@"dragging" options:NSKeyValueObservingOptionNew context:nil];

But observeValueForKeyPath:ofObject:change:context:it was not called, since UITableView.dragging does not have setter either, and this property does not correspond to KVO.

Is there any other way to archive this expectation when used scrollViewDidEndDragging:willDecelerate:?

Any help is appreciated! Thank!

+5
source share
2 answers

: , , , , , Apple UIScrollView, . , Mazyod, .


Apple iOS, UIScrollView, , , UITableView, , .

UIScrollView.h UIKit, _pan ivar, id, , -, UIPanGestureRecognizer.

, , , , .

 [_tableView addObserver: self 
              forKeyPath: @"pan.state" 
                 options: NSKeyValueObservingOptionNew 
                 context: nil];

state , , state UIGestureRecognizerStateEnded.

, , , , , . , , . NSKeyValueObserving ,

NSObject NSKeyValueObserving, .

, observeValueForKeyPath:ofObject:change:context: , ( , UITableView UIScrollView - KVO ). .

+8

, panGestureRecognizer, UIScrollView. , pan. .. , !

[_scrollView.panGestureRecognizer addTarget:self action:@selector(gestureRecognizerUpdate:)];

!

+8

All Articles