Zuhair Hussain Zuhair Hussain - 3 months ago 11
iOS Question

iOS 9 not retaining animations on back to old screen

I have an issue in my app in iOS 9. I have an animation on the first page of my app. It works fine for iOS 8 or earlier, but in iOS 9 phones when I go to next viewcontroller and come back to that viewcontroller animation stops. Here is my code.

-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:NO];
[UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction animations:^{
btnStartLearning.transform = CGAffineTransformMakeScale(1.3,1.3);
} completion:^(BOOL finished) {
}];
}


Anyone knows where is the problem.
Thanks,

Answer

Solved,

btnStartLearning.transform = CGAffineTransformIdentity;

before animation block

-(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:NO];
        btnStartLearning.transform = CGAffineTransformIdentity;
        [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction animations:^{
            btnStartLearning.transform = CGAffineTransformMakeScale(1.3,1.3);
        } completion:^(BOOL finished) {
        }];
 }