开发者

UIImageView consumes memory when hidden? (iOS)

Does UIImageView requires memory when it is hidden? Same question for alpha=0.0

I work a lot with hidden images, and I wonder if those still consume memory.

More specifically I would like to know that for tab开发者_如何学运维leview.

Thanks


Of course if it has an image loaded into the view, it does, because UIImageView is simply a UIView that has a UIImage @property with the retain attribute so it retains the image.

The fact that the view is visible or not does not change anything of course, and hopefully because otherwise iOS couldn't load the UIImage again if you set the UIImageView visible again (once the image property is affected to the UIImageView, the UIImageView can't know the source of the image, was it loaded from a file, an URL, generated programatically, ...?), and even if it did know it would be a pain to reload it (could take some time to load and decode)

If you don't use an UIImageView's image, at least set its image property to nil to hide it (and reload/reaffect the image again yourself if you need to redisplay it, but if it is used in a UITableView because of the recycling/reuse mechanism of the UITableViewCells it will probably never be the same image to set anyway)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜