Note that there are some explanatory texts on larger screens.

plurals
  1. POCABasicAnimation is not working when the method is called from the viewDidLoad
    primarykey
    data
    text
    <p>I have an imageView added to a view that's presented as a modalViewController, with style horizontal flip. I have added the following code for animating the imageView.</p> <pre><code>- (void)animateTheImageview:(UIImageView*) imageViewToAnimate{        CABasicAnimation *fadeAnimation;    fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];    fadeAnimation.duration = 1.5;    fadeAnimation.repeatCount = INFINITY;    fadeAnimation.autoreverses = NO;    fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];    fadeAnimation.toValue = [NSNumber numberWithFloat:0.5];    fadeAnimation.removedOnCompletion = YES;    fadeAnimation.fillMode = kCAFillModeForwards;    [imageViewToAnimate.layer addAnimation:fadeAnimation forKey:@"animateOpacity"]; } - (void)switchOnorOff {        if (onOffSwitch.on) {                self.lightImage.image = [UIImage imageNamed:@"CFLGlow.jpg"];        [self animateTheImageview:self.lightImage];    }    else {                self.lightImage.image = [UIImage imageNamed:@"CFL-BULB.jpg"];        [self.lightImage.layer removeAllAnimations];    } } </code></pre> <p>And I'm calling this method from the <code>viewDidLoad</code>:</p> <pre><code>- (void)viewDidLoad { [self switchOnorOff]; } </code></pre> <p>My issue is the above code doesn't animate the imageView.</p> <p>But when I tried the below code it works:</p> <pre><code>[self performSelectorOnMainThread:@selector(animateTheImageview:) withObject:self.lightImage waitUntilDone:YES]; </code></pre> <p>My question is why this issue is happening ? Is there any difference between,</p> <p><code>[self performSelectorOnMainThread:@selector(animateTheImageview:) withObject:self.lightImage waitUntilDone:YES];</code></p> <p>and </p> <p><code>[self animateTheImageview:self.lightImage];</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload