我写了一个小客户调查应用程序,在顶部我有一张汽车和一辆货车的图像,我假装它们正在放大。但是我编写它的方式将它变成了一个无限循环,其中一种方法调用另一种方法,反之亦然。这就是动画永远播放的原因。
这是我的代码
-(void)doAnimate {
// animate van
[UIView animateWithDuration:1.0
delay:7.f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
vanView.frame = CGRectMake(770, 175, vanView.frame.size.width, vanView.frame.size.height);
} completion:^(BOOL finished) {
if (finished) {
[self doAnimateLoop];
}
}];
// animate car
[UIView animateWithDuration:1.0
delay:3.f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
carView.frame = CGRectMake(-600, 250, carView.frame.size.width, carView.frame.size.height);
} completion:^(BOOL finished) {
if (finished) {
}
}];
}
-(void)doAnimateLoop {
vanView.frame = CGRectMake(-600, 175, vanView.frame.size.width, vanView.frame.size.height);
carView.frame = CGRectMake(770, 250, carView.frame.size.width, carView.frame.size.height);
// second animation van
// animate van
[UIView animateWithDuration:1.0
delay:2.f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
vanView.frame = CGRectMake(111, 175, vanView.frame.size.width, vanView.frame.size.height);
} completion:^(BOOL finished) {
if (finished) {
}
}];
// animate car
[UIView animateWithDuration:1.0
delay:5.f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
carView.frame = CGRectMake(104, 250, carView.frame.size.width, carView.frame.size.height);
} completion:^(BOOL finished) {
if (finished) {
[self doAnimate];
}
}];
}
我想知道这是否会在将来导致应用程序出现任何问题?像内存泄漏或可能导致它崩溃的东西。
任何帮助将不胜感激。