I’ve adopted a fairly well used method of flipping between two images. However on this occasion, for reasons currently beyond me – the animation is currently only flipping from “newView” to “newView.”
Any help pointing towards the error of my ways would be greatly appreciated. Code as follows:
UIImageView *oldView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dark_wood.png"]];
UIImageView *newView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"light_wood.png"]];
[container addSubview:oldView];
and:
[UIView transitionWithView:container
duration:2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ [oldView removeFromSuperview]; [container addSubview:newView]; }
completion:nil];
(It’s probably something v.simple beyond this code..)
The solution:
The method I was using to initiate the flip was at fault. I had a UISlider call for the flip – but without a system in place to stop it from doing so, it was continuously calling the flip animation – with the consequences as described!
Solution in code as follows:
Create a
BOOLto stop theUISliderrepeatedly calling the animation:IBAction for the UISlider:
Thanks to Tony for helping with this. A lesson if ever there was one to keep the script clean!