文档文件夹中的界面生成器图像
我需要支持视网膜显示,但应用程序大小必须很小。因此,我计划以非视网膜显示启动应用程序,然后获取视网膜图像[如果需要]并切换到视网膜显示图像。 唯一的问题是我的一些 UIViews 是用界面构建器构建的,据我所知,界面构建器的图像源是主包,而视网膜图像将下载到文档文件夹中。
有没有办法让界面构建器在运行时处理新的包?
问候 中号
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
界面构建器用于预先构建您的界面并将整个界面打包为一个整体包。它从主包中获取图像。而且你不能在运行时写入主包......所以......你被困住了。
但是...
如果您确实需要您正在谈论的动态工作风格,并且希望能够从文档文件夹中获取界面显示的图像,您可以这样做:
为了方便起见,将低分辨率图像保留到您的 IB 可以“查看”您正在做什么。但是,在 viewDidLoad 中,对于每个使用图像的项目,检查是否必须显示高分辨率图像,然后动态更改其 .image 属性,从文档文件夹加载高分辨率图像。为此,您将需要一些 IBOutlet,但这会起作用。
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.
虽然我认为图像不会对您的应用程序大小产生太大影响,除非它们不是 PNG,但您可以阅读更多详细信息 此处。
其他解决方案是将所有图像保存在服务器上,当用户第一次打开应用程序时,您可以检查设备类型,即是否是 iPhone 4 和 3/3GS,并根据它下载相关图像。
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.