ImageViewアニメーションに問題があります。私のビューには10を超えるビューがあり、各ビューはそのタグ値から識別されUIImageView
ますUIButton
。ボタンをタップすると、ビューの特定の画像をアニメーション化する必要があります。他の画像がアニメーション化されている場合は、停止する必要があります。これは私のコードです:
-(void)makeAnimation:(UIButton *)sender {
UIView *tagView=(UIView *)[self.view viewWithTag:sender.tag];
UIView *next=nil;
UIView *previous=nil;
NSLog(@"%d",sender.tag);
for (UIImageView * imageview in [tagView subviews]) {
if ([imageview isKindOfClass:[UIImageView class]]) {
if ([imageview isAnimating]) {
NSLog(@"Animation Happens");
}
else{
imageview.animationDuration=2.0;
imageview.animationImages=[animationArray objectAtIndex:sender.tag-1];
imageview.animationRepeatCount=2;
imageview.tag=sender.tag;
[imageview startAnimating];
}
}
}
next=(UIView*)[self.view viewWithTag:sender.tag+1];
previous=(UIView*)[self.view viewWithTag:sender.tag-1];
NSLog(@"NOT IDEA");
[self previousview:previous nextview:next];
}
-(void)previousview:(UIView *)previous nextview:(UIView*)next
{
for (UIImageView * imageview in [previous subviews]) {
if ([imageview isKindOfClass:[UIImageView class]]) {
[imageview stopAnimating];
NSLog(@"PRREVIOUS");
}
}
for (UIImageView * imageview in [next subviews]) {
if ([imageview isKindOfClass:[UIImageView class]]) {
[imageview stopAnimating];
NSLog(@"NEXT");
}
}
}
今私の問題は、4つ以上のボタンを次々に選択すると、メモリ警告でアプリがクラッシュすることです。