objective-c - Objective - C,在 UIImageView 中显示图像序列的最快方法

标签 objective-c ios performance ios4 uiimageview

<分区>

Possible Duplicate:
How to efficiently show many Images? (iPhone programming)

我有数百张图像,它们是一个动画的帧图像(每秒 24 张图像)。每张图片的尺寸都是1024x690

我的问题是,我需要在 UIImageView 中制作平滑动画迭代每个图像帧。
我知道我可以使用 UIImageView 的 animationImages。但由于内存问题,它崩溃了。

此外,我可以使用 imageView.image = [UIImage imageNamed:@""] 来缓存每个图像,以便下一个重复动画将流畅。但是,缓存大量图像导致应用程序崩溃。

现在我使用 imageView.image = [UIImage imageWithContentsOfFile:@""],它不会使应用程序崩溃,但不会使动画如此流畅。

也许有更好的方法来制作好的帧图像动画?

也许我需要做一些准备,以便以某种方式取得更好的结果。我需要你的建议。谢谢!

最佳答案

您可以尝试在内存中一次缓存 10 张图片(您可能需要考虑正确的限制——我怀疑是 10 张)。每次更改 imageView 的图像时,您都可以执行以下操作:

// remove the image that is currently displayed from the cache
[images removeObjectAtIndex:0];
// set the image to the next image in the cache
imageView.image = [images objectAtIndex:0];
// add a new image to the end of the FIFO
[images addObject:[UIImage imageNamed:@"10thImage.png"]];

关于objective-c - Objective - C,在 UIImageView 中显示图像序列的最快方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11130904/

相关文章:

iphone - 使用 openGL 和 cocos2D 绘制大量线条的最佳方法是什么?

ios - 将 Null 值和一个变量传递给 NSMutableArray/NSArray。为什么输出会有差异?

ios - cocoapods 集成后无法在设备中安装 IPA

ios - IOS 中的 Facebook 错误代码=7

ios - 在 iOS 应用程序中安排任务

algorithm - 根据性能分批拆分数据(负载均衡)

ios - SpriteKit 游戏中的风筝深度

objective-c - 需要从 SWIFT 到 Objective C 的转换帮助 "healthStore.requestAuthorizationToShareTypes"

iphone - 如何在运行时更改iPhone应用程序语言?

php - 使用 PHP 和 mySQL 实现标签系统。缓存帮助!