调用 nil 后 iPhone 内存没有释放

发布于 2024-12-10 10:09:19 字数 416 浏览 0 评论 0原文

我正在使用Apple的ScrollingSuite来显示带有许多大图像的大滚动视图。(768 x1024)图像视图的图像由其中设置

controller.numberImage.image = [self.contentList objectAtIndex:page]; 

,numberImage是UIImageView,控制器是我在滚动视图中添加的视图控制器的对象。当页面滚动到视图之外时,我将图像设置为 nil

controller.numberImage.image = nil;

但问题是我的应用程序在滚动图像时内存不足,收到内存警告。每次显示新图像时,我都可以看到仪器工具(内存标签 70)中的内存增加,谷歌搜索结果是 ImageIO。请帮助我

提前致谢

I am using Apple's ScrollingSuite for displaying a large scrollview with a number of large images.(768 x1024) The image of an imageview is set by

controller.numberImage.image = [self.contentList objectAtIndex:page]; 

where, numberImage is an UIImageView and controller is an object of the viewcontroller which I am adding in the scrollview. I am setting the image as nil when the page is scrolled out of view by

controller.numberImage.image = nil;

But the problem is my app runs out of memory receiving Memory Warning when scrolled through the images. Each time a new image is shown, I can see memory increasing in instruments tool (Memory Tag 70) which on googling turns out ImageIO. Please help me with this

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

演出会有结束 2024-12-17 10:09:19

尝试删除 imageView ( [controller.numberImage removeFromSuperview]; ),然后在它即将进入视图之前将其添加回来 ( [controller addSubview:[[UIImageView alloc] initWithImage:[self .contentList objectAtIndex:page]]]; )可能吗?

Try removing the imageView ( [controller.numberImage removeFromSuperview]; ), then adding it back before it is about to come into view ( [controller addSubview:[[UIImageView alloc] initWithImage:[self.contentList objectAtIndex:page]]]; ) possibly?

风月客 2024-12-17 10:09:19

对于此类问题,可以有各种解决方案,所以...

  1. 我认为您可以像 [controller.numberImage removeFromSuperview] 一样删除 imageview,并在需要时再次分配图像 UImageView。它可以是第一个解决方案。

  2. 如果我解释一下,一次可以加载 3 个图像,然后加载当前图像、上一个图像和下一个图像。这意味着如果您想查看图像 2,则一次加载三个图像:图像 1、图像 2 和图像 3。当您滚动到下一个图像时,然后加载图像 2、图像 3 和图像 4 并释放图像 1...等等...反之亦然,用于加载图像上

  3. 最糟糕的解决方案是尝试降低图像分辨率而不改变图像的大小。

Various kinds of solution can be for such kinds of problem so...

  1. I think you can remove the imageview like [controller.numberImage removeFromSuperview] and alloc the image again when you need the UImageView.it can be first solution.

  2. At a time you can load 3 images if i explain then load the present image,previous image and next image.thats mean if you want to see the image 2 load at a time three images,image 1,image 2,and image 3. when you will scroll to next image then load image 2,image 3 and image 4 and dealloc the image 1...and so on...vice versa for loading image previous image loading.

  3. the worst solution is try to decrease the image resolution without changing the size of the image.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文