没有@ 3x图像的应用程序稀疏,当某些图像是JPG时 [英] App thinning without @3x images and when some images are JPGs

查看:151
本文介绍了没有@ 3x图像的应用程序稀疏,当某些图像是JPG时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的某个应用程序的即将更新,我已将所有图像资源打包到资产目录中。

For an upcoming update to one of my apps I have packed all the image resources into Asset Catalogs.

但是,目前我还没有@ 3x版本对于我的大多数图像。我已经使用模拟器进行了检查,并且使用了iPhone 6 Plus @ 2x版本。

However, at the moment I do not have @3x version for most of my images. I have checked with the simulator and on iPhone 6 Plus @2x versions are used.

我不介意这种行为有两个原因:

I don't mind this behaviour for two reasons:


  1. 结果对我正在使用的图像足够好

  2. 只有50%的用户使用iOS 9.如果我添加@ 3x图像我的应用程序的大小将为旧操作系统上的用户增加。

尽管图像在iPhone 6加上模拟器中正确加载,我有点担心存档我的应​​用时会发生什么。特别是,我担心使用App Thinning iPhone 6 Plus用户将获得一个没有任何图像的应用程序:)

Although images load correctly in the Simulator for iPhone 6 plus, I am a bit worried about what happens when I archive my app. In particular, I am afraid that with App Thinning iPhone 6 Plus users will get an app without any images :)

所以,我有两个问题:


  1. 如果我不提供@ 3x图像,我的更新将在App Store上线后,iPhone 6加上
    会加载@ 2x吗?

  2. 我仍然可以从App Thinning中受益,因为使用@ 2x和
    @ 3x显示器的用户不会下载@ 1x图像(反之亦然)?或者App Thinning在这种情况下不起作用,用户将获得相同的资产而不管其设备的屏幕是什么?

这些是微不足道的问题,但我无法在网上找到任何信息,当你不遵守Apple的指导原则时,如果不在资产目录中提供@ 3x图像,但你的应用程序仍可用于iPhone 6 +。此外,我的一些图像采用JPG格式,这增加了额外的不确定性,因为它不是iPhone的理想格式。

These are trivial questions, but I couldn't find info anywhere online as to what happens when you do not follow Apple's guidelines by not providing @3x images in asset catalogs but your app is still available for iPhone 6 +. In addition, some of my images are in JPG format which adds extra uncertainty because it is not an ideal format for iPhone.

提前感谢您的任何帮助!

Thanks in advance for any assistance!

推荐答案

我使用Matt提出的程序进行了几项额外的测试:

I performed several additional tests using the procedure proposed by Matt:


  1. 当最低部署目标是iOS 6时,没有Assets.car生成
    [UIImage imageNamed:] 为JPG图片返回 nil ,除非.jpg扩展名作为图片名称的一部分提供

  2. 当最低部署目标是iOS 7时,会生成Assets.car但
    它只包含那些在资产目录
    中作为PNG导入的图像。所有JPG都被复制到Assets.car之外。 [UIImage imageNamed:] 为JPG图片返回 nil ,除非.jpg扩展名作为图片名称的一部分提供。

  3. 当最低部署目标是iOS 8时,Assets.car包含所有
    图像。它的大小是13MB。 [UIImage imageNamed:] 即使未指定.jpg扩展名也能正确返回JPG图像。当包含.jpg扩展名时,图像也会正确加载

  4. 当最低部署目标是iOS 9时,Assets.car包含所有
    图像。它的大小是11.5MB。 [UIImage imageNamed:] 即使未指定.jpg扩展名也能正确返回JPG图像。当包含.jpg扩展名时图像也会正确加载

  1. When minimum deployment target is iOS 6 no Assets.car is being generated. [UIImage imageNamed:] returns nil for JPG images unless ".jpg" extensions is provided as part of the image name
  2. When minimum deployment target is iOS 7 Assets.car is generated but it contains only those images which were imported in Asset Catalog as PNGs. All JPGs get copied outside of Assets.car. [UIImage imageNamed:] returns nil for JPG images unless ".jpg" extensions is provided as part of the image name.
  3. When minimum deployment target is iOS 8 Assets.car contains all images. Its size is 13MB. [UIImage imageNamed:] returns JPG images correctly even when not specifying ".jpg" extension. Images also load correctly when ".jpg" extension is included
  4. When minimum deployment target is iOS 9 Assets.car contains all images. Its size is 11.5MB. [UIImage imageNamed:] returns JPG images correctly even when not specifying ".jpg" extension. Images also load correctly when ".jpg" extension is included

我使用了图像提取工具由Matt建议从这些资产中提取图像。我只能从档案中导出带有Retina的设备,我可以确认所有图像都具有正确的分辨率(即只有视网膜尺寸,iPad特定图像被忽略)。但是,该工具以PNG格式保存了所有文件,因此文件夹的最终大小始终大于Assets.car。

I have used the image extractor tool suggested by Matt to extract images from these Assets. I was only able to export from archives for devices which are with Retina and I can confirm that all images had correct resolutions (i.e. only retina size, iPad specific images ignored). The tool, however, saved all of them in PNGs format and so the resulting size of the folder was always bigger then Assets.car.

最令人惊讶的是,案例3和4的文件夹大小相同(39.4MB)。此外,图像似乎完全相同。所以,我真的很想知道那里会发生什么,因为这些情况下Assets.car的大小相差2MB。

What is most surprising is that the size of the folder was the same (39.4MB) for cases 3 and 4. Also, the images seem to be exactly the same. So, I really wonder what happens there because there is a difference of 2MB in the size of Assets.car for these cases.

总之,我们仍然不确定这种测试方法可用于准确模拟App Thinning行为。所以,如果有人有这方面的个人经验,如果他们可以分享它就会很棒。

To conclude, we are still not sure if such testing method can be used to accurately mimic the App Thinning behaviour. So, if anyone had a personal experience with this it would be awesome if they could share it.

但是,假设为特定设备导出AdHoc会产生与App Store实际应用程序细化我们可以得出结论:

However, assuming that exporting for specific device for AdHoc produces the same result as actual App Thinning performed by App Store we can conclude that:


  1. 应用程序细化仅在部署目标为iOS 7或更高版本时启动

  2. JPG图像的应用程序细化仅适用于iOS 8的最低部署目标

  3. [UIImage imageNamed:] 才能正确返回JPG图像而不提供.jpg扩展名。如前所述,仅在最低部署目标为iOS 8或更高版本时才会发生

  4. [UIImage imageNamed:] 始终加载正确的图像如果指定了.jpg扩展名。

  1. App thinning only kicks in when deployment target is iOS 7 or later
  2. App thinning for JPG images only works starting from a minimum deployment target of iOS 8
  3. [UIImage imageNamed:] returns JPG images correctly without providing ".jpg" extension only when JPG images are correctly processed through Asset Catalogs. Which, as mentioned earlier, only happens when minimum deployment target is iOS 8 or later
  4. [UIImage imageNamed:] always loads correct images if ".jpg" extensions is specified.

最后两个结论似乎与这个问题无关,但我发现有几个冲突关于如何使用资产目录正确加载JPG图像的Stack Overflow的意见。有些人声称你可以加载它们而不提供.jpg扩展名,而其他人抱怨这种方法不起作用。我认为上面的3和4详细解释了这种情况下发生的情况以及为什么人们会得到不同的结果。

The last two conclusions seem to be irrelevant to this question, but I have found several conflicting opinions on Stack Overflow about how to load JPG images correctly with Asset Catalogs. Some people claimed that you can load them without providing ".jpg" extension whilst others complained that this approach doesn't work. I think 3 and 4 above explain in details what is happening in this case and why people get different results.

这篇关于没有@ 3x图像的应用程序稀疏,当某些图像是JPG时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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