Why isn't my Asset Catalog returning R4 images?

不羁的心 提交于 2020-01-01 07:35:25

问题


I'm in the process of migrating my images to an Asset Catalog. My app needs to access the Launch Image after launch and display it on the screen.

Easy enough, but I have different images for short and tall iPhones, and my iPhone 5 is loading the short launch image when I call [UIImage imageNamed:@"LaunchImage"].

Okay so maybe I can't do this with a Launch Image. I'll try putting some images in a normal Image Set instead.

No dice. Using an iPhone 5, when I call [UIImage imageNamed:@"Derp"] OR when I set an image in Interface Builder, I get the 2x (retina) image instead of the R4 (retina 4-inch) image.

Is this feature broken? How to I get the R4 image on my iPhone 5 (iOS 7)?


回答1:


For the R4 image to be automatically selected by Xcode you have to change the iOS Target to iOS 7. So even if you use the iOS7 SDK, your project target must be iOS 7.




回答2:


I have found answer thanks to this. Subtype R4 in Asset Catalog works only with iOS 7 and higher. In other case it will use @2x image.




回答3:


I have same issue and scratched hours. I use localized launch images which make it more complicate. After all, I just change back and not use asset catalog. Name the launch images as Default.png , Default@2x.png and Default-568@2x.png. Localized and Put them in the bundle and make ios recognize automatically. Everything works fine.




回答4:


The R4 image worked for me only with this process:

  1. Delete the problem Image View from the storyboard
  2. Add a brand new Image View to replace it with the expected asset name, e.g. "Derp"



回答5:


The solution that we have used is to update the asset catalog and target only iOS 6 and Prior.

How to do it. Go to the asset catalog. And on the top right corner click on the 'Attribute Inspector' icon. Here you can set the Target OS for the Launch Images. Uncheck the iOS 7 check boxes for iPhone. Now you should be able to see the launch images for these devices. Doing this you will use the 2x Image for R4 as well.



来源:https://stackoverflow.com/questions/18924321/why-isnt-my-asset-catalog-returning-r4-images

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!