我已經寫了一個小客戶調查應用程序,在頂部我有一輛汽車和一輛麪包車,我假裝的圖像放大。但是我編碼的方式將它變成了一個無限循環,其中一個方法調用另一個方法,反之亦然。這就是動畫永遠播放。一種方法永遠調用另一種方法,這會導致任何問題嗎?
這裏是我的代碼
-(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];
}
}];
}
我想知道這是怎麼回事導致在未來的應用程序的任何問題?像內存泄漏或可能導致它崩潰的東西。
任何幫助將不勝感激。