Is UIScrollView blocking a loop cycle?

I implemented NSTimer (repeats) and UITableView on the same viewController.

Somehow, when I look at the View table, the start loop does not seem to start NSTimer. The same goes for UITextView, which is also a subclass of UIScrollView.

Can I find out what's going on here?

+2
source share
1 answer

The reason the timer stops firing is because the run cycle is switched to UITrackingRunLoopModeduring scrolling, and by default this timer is not added to this mode. You can do this manually when starting the timer:

NSTimer *timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:YES];
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
[runloop addTimer:timer forMode:NSRunLoopCommonModes];
[runloop addTimer:timer forMode:UITrackingRunLoopMode];
+9
source

All Articles