在 iOS 4.0 上使用大图像时应用程序崩溃 [英] App Crashing when using large images on iOS 4.0
问题描述
我在滚动视图上显示大图像时遇到了问题,图像大小为 2,4 - 4,7 MB.它在 3GS 和模拟器上运行良好.但每当我尝试在 3G 或 iPod Touch 2G 上运行时,它就会崩溃.
I've been having a problem to show large images on a scrollview, the images are 2,4 - 4,7 MB. It runs fine on the 3GS and on the simulator. But whenever I try to run on a 3G or iPod Touch 2G, it crashes.
我在网上搜索并找到了imageNamed is evil"的文章.好的,我将所有图像调用更改为 imageWithContentsOfFile: 但它仍然崩溃,我看到的唯一不同是现在图像在我离开视图后被释放就好了.但是内存使用率还是很高的.
I searched across the web and found the "imageNamed is evil" article. Ok I changed all my image calls to imageWithContentsOfFile: but it still crashes, the only different that I see is that now images are deallocated after I leave the view just fine. But the memory usage is still very high.
这是 Instruments 的屏幕截图.第一个高峰是我在启动时显示的视频,然后tableview显示了很多图像,直到那时没有问题.
Here is a screenshot of Instruments. First peak is a video I show at startup, then the tableview shows a lot of images, until then no problems.
当我输入 1.1mb - 2576 x 1000 图片时
当我输入 4.8mb - 7822 x 1000 图片时
顺便说一下,该应用在 iOS 4 和 3.1.2 上进行了测试
By the way the app was tested on iOS 4 and 3.1.2
你有什么建议吗?因为这个问题快把我逼疯了.
Do you have any tips? Because this problem is driving me nuts.
非常感谢!
推荐答案
我最终使用了 UIWebView,我不得不使用更小(以 MB 为单位,而不是尺寸)的图像,但它正在工作,唯一的问题是我不能缩放...使用 scalePageToFit 我可以缩放,但图像水平而不是垂直适合,sux.
I ended up using UIWebView, I had to use smaller (in MB, not dimensions) images but it's working on, the only problem Is that I can't zoom... Using the scalePageToFit I can zoom but the image fits horizontally not vertically, that sux.
我会努力更新这个问题.
I will try to keep this issue updated.
如果有人遇到这个问题,我建议使用 webview 或可以更好地处理内存的 three20 图像查看器的适配器版本.
If someone has this problem I would advice to use webview or an adapter version of three20 image viewer that handles memory better.
这篇关于在 iOS 4.0 上使用大图像时应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!