Question

This app uses NSTimer for triggering images at a certain timeInterval. This works fine but when you zoom in, problems start to occur, the timeIntervals between the images are not constant any more. I have tried two different codes for my timer and they both do not work.

_timerForImageTrigger = [NSTimer scheduledTimerWithTimeInterval:_timeIntervall target:self selector:@selector(automaticTriggerImage) userInfo:nil repeats:YES];

_timerForImageTrigger = [NSTimer timerWithTimeInterval:_timeIntervall
                                             target:self
                                           selector:@selector(automaticTriggerImage)
                                           userInfo:nil
                                            repeats:YES];
    [[NSRunLoop mainRunLoop] addTimer:_timerForImageTrigger forMode:NSRunLoopCommonModes];

What I have done now is disabled zooming when the camera is in record mode. But this is not a solution I want to stick to. Are there any ideas how to fix this or where the problem could be?

Était-ce utile?

La solution

NSTimers are not guaranteed to fire exactly on time. I believe because your timer is on the main thread it is delayed by other activity on the main thread such as zooming.

This might be helpful Stack Question

You might what to try running the timer on a background run loop.

N.B if you are updating the UI you have to do this on the main thread.

Also you might want to consider changing the tolerance (iOS 7) NSTimer

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top