Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective-C,在UIImageView中显示图像序列的最快方法_Objective C_Ios_Performance_Ios4_Uiimageview - Fatal编程技术网

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

Objective-C,在UIImageView中显示图像序列的最快方法,objective-c,ios,performance,ios4,uiimageview,Objective C,Ios,Performance,Ios4,Uiimageview,可能重复: 我有数百个图像,它们是一个动画的帧图像(每秒24个图像)。每个图像大小为1024x690 我的问题是,我需要在UIImageView 我知道我可以使用UIImageView的动画图像。但由于内存问题,它崩溃了。 另外,我可以使用imageView.image=[UIImage imageNamed:@”“]来缓存每个图像,以便下一次重复的动画将平滑。但是,缓存大量图像使应用程序崩溃。 现在我使用imageView.image=[UIImage imageWithContentsOf

可能重复:

我有数百个图像,它们是一个动画的帧图像(每秒24个图像)。每个图像大小为1024x690 我的问题是,我需要在UIImageView
我知道我可以使用UIImageView的动画图像。但由于内存问题,它崩溃了。

另外,我可以使用
imageView.image=[UIImage imageNamed:@”“]
来缓存每个图像,以便下一次重复的动画将平滑。但是,缓存大量图像使应用程序崩溃。

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

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


也许我需要做一些准备,以达到更好的效果。我需要你的建议。谢谢大家!

你可以在这里找到答案:


总结一下在该链接中所说的,如果您使用低级别API(如核心动画和OpenGL)来显示许多图像,您将获得更好的性能,这与UIKit相反

你可以试着在内存中一次缓存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"]];

可以使用数组创建多个图像的缓冲区。可以使用来自后台线程(例如并发GCD异步)的imageWithContentsOfFile加载/填充此图像缓冲区数组。

UIImageView*animation.frame=[UIImageView新建];animation.animationImages=animationFrames;//图像数组animation.animationDuration=1.25;animation.animationRepeatCount=1;animation.hidden=是;试试这个