iPhone使用UIImageView进行大量动画的最佳实践 [英] iPhone Best practices for large number of animations using UIImageView

查看:129
本文介绍了iPhone使用UIImageView进行大量动画的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需要在iPhone上请求动画图像的一些建议。我正在构建一个由5个动画角色组成的应用程序。

Just requesting a little advice animating images on the iphone. I'm building an app that consists of a character with 5 animations.

每个动画由大约50张图片组成,平均持续时间为3秒。

Each animation consists of roughly 50 images with an average duration of 3 seconds.

我打算创作每个动画的图像数组,将这些作为UIImageView的源,并根据需要切换它们。但是你可以猜测这种方法会杀死我的iphone的内存,从而杀死应用程序。 (250张图片@ 130K每张!)

I was going to create an array of images for each animation, have these as the source for an UIImageView and switch these as needed. But as you can guess this approach kills my iphone's memory and thus the app. (250 images @ 130K each!)

所以这让我想知道其他人是如何解决这个问题的?也许将动画更改为电影?

So this got me wondering how other people get around this? Maybe change the animations to movies?

感谢您的任何建议。

推荐答案

<如果你能逃脱它,我会推荐电影路线。它会更干净,性能也更高。

I'd recommend the movie route, if you can get away with it. It'll be cleaner and likely much more performant.

然而,如果你出于某种原因陷入图像困境,那么连续加载5000张全帧图像的表现就是:

However, if you're stuck with images for some reason, here's performance from loading 5000 full-frame images in succession:

[UIImage imageWithData:...] // 44.8 seconds

[UIImage imageWithContentsOfFile:...] // 52.3 seconds

[[UIImage alloc] initWithContentsOfFile:…] // 351.8 seconds

[UIImage imageNamed:...] // hung due to caching

这篇关于iPhone使用UIImageView进行大量动画的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆