我必须不断更改 ImageView 的图像。但是在更改时,我收到了内存警告并崩溃了。
最佳答案
当我在我的应用程序中做某事时,您只需将所有图像放在一个数组中。您可以尝试,因为图像是基于持续时间的变化。你可以做..
UIImage *img1 = [UIImage imageNamed:@"1.png"];
UIImage *img2 = [UIImage imageNamed:@"7.png"];
UIImage *img3 = [UIImage imageNamed:@"8.png"];
UIImage *img4 = [UIImage imageNamed:@"9.png"];
UIImage *img5 = [UIImage imageNamed:@"10.png"];
animationImages = [[NSArray alloc] initWithObjects:img1,img2,img3,img4,img5,nil];
[imgView setAnimationImages:animationImages];
[imgView setAnimationDuration:1.5];
[imgView startAnimating];
然后在要停止此效果的位置应用 [imgView stopAnimaiton]。这对我来说可以。
关于objective-c - 连续更改 Imageview 图像在 iphone sdk 中给出内存警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10547210/