Interface builder images from the document folder
I need 开发者_开发知识库to support retina display but the app size has to be small. Therefore I am planning to start the app with non-retina display, then fetch the retina images [If required] and switch to the retina display images. The only problem is that some of my UIViews built with interface builder, and as far as I know interface builder's image source is the main bundle, while the retina images will be downloaded to the document folder.
Is there a way to let the interface builder a new bundle to work on in run time?
Regards M
Interface builder is used to pre-build your interfaces and package the whole thing as an all-in-one-packet. And it takes its images from main bundle. And you can't write at runtime into the main bundle... So... You're stuck.
But...
If you really need the dynamic style of working you're talking about, and want be able to get the displayed images for your interface from the Document folder, you could do this :
Keep for convenience the low-res images into your IB to "see" what you're working on. But, in viewDidLoad, for each item that uses an image, check if you have to display a high-res image then change dynamically its .image property loading your high-res image from the Document folder. To do that yo will need some IBOutlets, but that will work.
Though I don't think images should make too much difference to your app size unless of course they are not PNG, you can read more details here.
Other solution would be to save all your images on server and when user opens the app for the first time, you can check the device type i.e. if it's iPhone 4 and 3/3GS and depending on it, download the relevant images.
精彩评论