[英]iOS 6.1 animation not working
The following method that i created for animation: 我为动画创建的以下方法:
-(void)shakingAnimationForGate:(UIImageView *)image leftShaking:(CGAffineTransform)leftTransform rightShaking:(CGAffineTransform)rightTransform animationName:(NSString *)string{
[UIView animateWithDuration:5.0
delay:0.5
options: UIViewAnimationOptionCurveEaseOut
animations:^{
image.transform = leftTransform; // starting point
[UIView beginAnimations:string context:(__bridge void *)(image)];
[UIView setAnimationRepeatAutoreverses:YES]; // important
[UIView setAnimationRepeatCount:20];
[UIView setAnimationDelay:0.1];
[UIView setAnimationDuration:0.06];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(shakeEnded:finished:context:)];
image.transform = rightTransform; // end here & auto-reverse
[UIView commitAnimations];
}
completion:^(BOOL finished){
NSLog(@"end of shaking");
}];
}
which makes UIView do the "shaking". 这使得UIView可以“摇晃”。
Then i'm using this method: 然后我正在使用这种方法:
CGAffineTransform leftShake = CGAffineTransformMakeTranslation(-2, 6);
CGAffineTransform rightShake = CGAffineTransformMakeTranslation(0, 3);
[self shakingAnimationForGate:imageLeft leftShaking:leftShake rightShaking:rightShake animationName:@"left view shake"];
where imageLeft is UIImageView . 其中imageLeft是UIImageView 。
So my problem is that this method don't do animation of shaking on iOS 6.1. 所以我的问题是,这种方法无法在iOS 6.1上播放动画。 It's working fine on iOS 7 though.
虽然在iOS 7上运行良好。 Any ideas what's the problem?
有什么问题吗?
When compiling, Xcode optimises your code a little. 编译时,Xcode会稍微优化您的代码。 For example if you execute the following code, only the last line is executed:
例如,如果执行以下代码,则仅执行最后一行:
[self.view setBackgroundColor:[UIColor greenColor]];
[self.view setBackgroundColor:[UIColor yellowColor]];
Most likely that's the case with the animation as well. 动画也很可能也是这种情况。
Move the revert part to the completion part. 将还原部分移动到完成部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.