General Failure General Failure - 1 year ago 108
Objective-C Question

How can I detect scrolling for update before end dragging event in iOS?

I want to add update gesture in some views in my iOS application

Usually this gesture is scroll above top and hold for some small time

I could make just gesture handler that works if user did hold scrolled view more than 1 second:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if (scrollView == _tableView) {
_scrollViewDragStarted = [NSDate date];

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
if (scrollView == _tableView) {
if (velocity.y < 0 && targetContentOffset->y < 0) {
NSTimeInterval hold = [[NSDate date] timeIntervalSinceDate:_scrollViewDragStarted];
if (hold > 1) {
// refreshing method calls here
_scrollViewDragStarted = nil;

It works perfectly but hint about holding is needed when user scrolled view above top

How can I detect such scrolling?
event has no scroll parameters as

Or maybe exist another way to implement this?

Answer Source

Try using scrollViewDidScroll(_:).

Note that you can use UIScrollView.contentOffset.y < 0 to check whether it has scrolled above the top.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download