私は小さな顧客調査アプリケーションを作成しました。上部には、ズームしているふりをしている車とバンの画像があります。しかし、私がコーディングした方法では、一方のメソッドがもう一方のメソッドを呼び出す無限ループになり、その逆も同様です。これにより、アニメーションが永遠に再生されます。
これが私のコードです
-(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];
}
}];
}
これが将来アプリに問題を引き起こすかどうか知りたいですか?メモリリークやクラッシュの原因となる可能性のあるものなど。
どんな助けでも大歓迎です。