The NSTimer that is used to handle the graceTime property is created using + [NSTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:], which, according to the documentation, schedules it on the current run loop in the default mode. This means that the timer will not fire if the main run loop is in an other mode.
Typically, when you drag a scrollView, as long as you keep your finger down, the run loop mode will be UITrackingRunLoopMode and the timer will not fire until you lift your finger and the run loop mode goes back to kCFRunLoopDefaultMode.
I suggest scheduling the timer manually using NSRunLoopCommonModes, which includes the Default and the UITracking modes.
So I would replace this :
self.graceTimer = [NSTimer scheduledTimerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO];
by this :
NSTimer *newGraceTimer = [NSTimer timerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO];[[NSRunLoop currentRunLoop] addTimer:newGraceTimer forMode:NSRunLoopCommonModes];self.graceTimer = newGraceTimer;
I'm not sure it is that crucial to be super accurate in that case, but I guess dismissing the HUD shouldn't impact scroll performance that much anyways. Added in b1564fd.
The NSTimer that is used to handle the graceTime property is created using
+ [NSTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:]
, which, according to the documentation, schedules it on the current run loop in the default mode. This means that the timer will not fire if the main run loop is in an other mode. Typically, when you drag a scrollView, as long as you keep your finger down, the run loop mode will beUITrackingRunLoopMode
and the timer will not fire until you lift your finger and the run loop mode goes back tokCFRunLoopDefaultMode
. I suggest scheduling the timer manually usingNSRunLoopCommonModes
, which includes the Default and the UITracking modes.So I would replace this :
self.graceTimer = [NSTimer scheduledTimerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO];
by this :NSTimer *newGraceTimer = [NSTimer timerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:newGraceTimer forMode:NSRunLoopCommonModes];
self.graceTimer = newGraceTimer;