I have a method running performSelector on itself every .01 seconds in order to constantly update an image.
-(void)setNeeds
[mag setNeedsDisplay];
[vc setNeedsDisplay];
[na setNeedsDisplay];
[wave setNeedsDisplay];
[mon setNeedsDisplay];
[self performSelector:@selector(setNeeds)
withObject:NULL
afterDelay:.01];
This updates just fine when there is normal user interaction. However, when a user slides values around on the UIViewPicker, all updates are paused until the interaction stops. The same thing happens with an NSTimer object set on repeat.
I'm hoping for a more consistent method of performing a continuous action but a solution to this problem would also be grand.
This is a fairly common question since an
NSTimercreated withscheduledTimerWith...may pause while there is user interaction. Here is a similar question. TheperformSelector:..afterDelay:..methods use anNSTimerinternally, as you would imagine. Basically when you usescheduledTimerWith...orperformSelector:..afterDelay:..your timer is scheduled in the run loop forNSDefaultRunLoopModewhich may pause while the user is interacting with the application. The solution is to schedule the timer in the run loop yourself forCommonModeslike so:If you are opposed to managing your own
NSTimerfor this function, then you can use theperformSelector:withObject:afterDelay:inModes:function. The final argument is an array of run loop modes, in which you may putNSRunLoopCommonModes.