iphone - iPad : UIImage imageWithContentsOfFile performance problems

标签 iphone performance uiimage

我需要在 iPad 上显示 20 x 15 网格的图像。每个图像的尺寸为 50 像素 x 50 像素。

我正在使用 [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"name"ofType:@"png"]] 来执行此操作,但遇到了性能问题。应用程序严重滞后。有 14 种不同类型的图像,均为 png 格式,尺寸为 50x50。

有没有一种方法可以用来提高性能?

更新:我尝试使用以下链接中找到的解决方案;这对一些人有所帮助,但并没有完全解决问题。希望它对其他人有帮助。 http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/

最佳答案

imageNamed 将缓存图像,因此第二次使用时速度会更快。如果这没有帮助,那么您可以在内存受到不太严重影响的情况下预加载图像,然后将它们从 NSArray 或 NSMutableArray 中交换出来例如。

关于iphone - iPad : UIImage imageWithContentsOfFile performance problems,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3927519/

相关文章:

iphone - 在 iPhone 上通过 SMS 发送位置信息或 vCard

ios - iPhone 无法正确完成应用内交易 (IOS7)

java - 创建新变量与重用旧变量哪个更快?

android - 应用程序使应用程序屏幕变慢

ios - 以编程方式将 UIButtons 添加到 UICollectionView 单元格的 uiimage

iphone - 在 ios 中使用自动释放池的限制

ios - 在 UINavigationController 中第一次运行时推送 View

java - 在 Android 中存储/保存下载图像的最佳方式哪种方式更适合离线模式和同步?

ios - 打开简历。以灰度而不是 RGB 形式返回的图像

ios - 在图像上绘制内容后,我的 ImageView contentmode 停止工作