objective-c - 连续更改 Imageview 图像在 iphone sdk 中给出内存警告

标签 objective-c ios

我必须不断更改 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/

相关文章:

objective-c - NSCursor 设置不适用于未聚焦的窗口

ios - 如何在 ios 中创建三角形对象

ios - 我的应用程序一直提供 UILocalNotifications,即使代码中没有

iOS 重大变更频率

ios - 当前 View Controller :animated:completion wont Animate

objective-c - 在基于 NSTableView 的 View 中获取 NSPopUpButton 的行

html - 横幅高度不是仅在 iPad 上的设备高度

ios - 如何知道要删除哪个子层?

ios - Storyboard以反向预览显示 View Controller (Xcode 8.3.2)

c++ - C定义格式问题