是否在缓存的xib中分配了图像? [英] Are Images assigned in a xib cached?

查看:131
本文介绍了是否在缓存的xib中分配了图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将图像分配给xib中的 UIImage 视图,该图像是否已缓存,以便在使用 UIImage imageNamed:访问图像时,我将获得缓存Image数据?

If I assign an image to a UIImage view in a xib, is that image cached so that if I access the image using UIImage imageNamed: I am getting cached Image data?

我正在使用iOS 5.1

I'm using iOS 5.1

推荐答案

UIImage imageNamed:自己缓存你使用的任何图像。第一次将它用于给定图像时,它将填充缓存,然后它将使用缓存版本。

UIImage imageNamed: does its own cacheing of any images you use. The first time you use it for a given image, it'll populate the cache, and subsequently it'll use the cached version.

UIImageView Interface Builder中的接受一个字符串来告诉它使用什么图像。实际上在Xib中编码以表示图像的对象似乎是一个名为 UIImageNibPlaceholder 的私有类,它包含一个名为 runtimeResourceName的私有NSString变量。这个类实现了 initWithCoder:方法,该方法在系统从xib加载对象时使用。

UIImageView in Interface Builder takes a string to tell it what image to use. It appears that the object that is actually encoded in the Xib to represent the image is a private class called UIImageNibPlaceholder, which contains a private NSString variable called runtimeResourceName. It's this class that implements the initWithCoder: method which is used when the system is loading objects from a xib.

所以,问题是,在 UIImageNibPlaceholder initWithCoder:里面,它是否使用 imageNamed : UIImage 的功能?我认为这样做是合理的,因为存储在xib中的东西是字符串 runtimeResourceName ,并且系统在加载xib时将该字符串转换为实际图像。

So, the question is, inside UIImageNibPlaceholder's initWithCoder:, does it use the imageNamed: function of UIImage? I think it's reasonable to assume that it does, since the thing stored in the xib is the string runtimeResourceName, and the system is turning that string into an actual image when loading the xib.

Apple开发人员论坛上的这篇文章似乎澄清要点(在NDA下,所以我不能在这里复制)。我找不到任何有关此主题的公开信息。

This post on the Apple developer forums seems to clarify the point (under NDA so I can't copy it here). I couldn't find any publicly accessible information on the subject.

这篇关于是否在缓存的xib中分配了图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆