Search code examples
iosios5core-animationios4

animateWithDuration:delay:options:animations:completion: blocking UI when used with UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse


I'm running a function to pulse a play icon:

- (void)pulsePlayIcon {
    if ([self isPlaying]) {
        return;
    }

    [[self videoView] playIcon].hidden = NO;
    [[self videoView] playIcon].alpha = 1.0;

    [UIView animateWithDuration:[self playIconPulseDuration] 
                          delay:[self playIconPulseTimeInterval] 
                        options:(UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse) 
                     animations:^{
                         [[self videoView] playIcon].alpha = 0.8;
                     } 
                     completion:^(BOOL completed) {}];
}

This works wonderfully in iOS 5.0, but in 4.3 it blocks the UI. The UI doesn't respond. I read that this was the suggested way to do repeating animations in iOS version 4.0 or greater (>= 4.0). The culprit seems to be UIViewAnimationOptionRepeat. Do you see any obvious errors I'm making?


Solution

  • You should probably be including UIViewAnimationOptionAllowUserInteraction as well.