iPhone Best practices for large number of animations using UIImageView(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 处理大量动画的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone 使用 UIImageView 处理大量动画的最佳实践


- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01