问题
So just when I though my swift 2 upgrade could not get any worse its seems that you cannot add retina 4" 2x image assets anymore. I cannot fine any option anymore to add it, all my old assets still have the retina 4" image but I cannot create a new image set with a 4" retina image. Why?
Any ways to fix this?
回答1:
Edit Contents.json
of the Image Set
and add
{
"idiom" : "iphone",
"subtype" : "retina4",
"scale" : "2x"
}
You will see appear Retina 4 2x
entry.
回答2:
so I asked them again what we should do if we need to scale images precisely for the 4 inch retina screen.
"What is preventing you from being able to apply the special casing code whereby you check the device type and do something different for iPhone 5, 5s, 5c?
i.e.
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (GSM)";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)"
Have you filed a feature request for this ability yet? (using Apple Bug Reporter) "
Not really satisfied with the answer at all because I obviously know how to check what kind device is running my app/game.
How does that help me to add a image to my asset catalogue that is only used for the retina 4 inch screen? You know like I could do before without any issues at all. It seems beyond stupid to remove retina 4 inch assets, makes no sense to me.
Also in regards to the JSON tip for Giorgio, it still seems to work actually, i think my simulator on a iPhone 5 is just messed up.
回答3:
Spoke to apple, turns out they removed it on purpose.
Basically this is the answer I got. I was having a TSI open for another issue so didn't ask further questions.
"Regarding the lack of 4” iPhone image sets in Assets Catalogs (in Xcode 7+) our assets catalog supporter, Justin, says its been removed by design and to file an enhancement request if you want it back. When you do, however, be sure it tell the assets catalog team your use case and why you need it. There are a number of solutions to consider as the way to cope with this moving forward but I encourage you to file a new TSI to talk with Justin more about it."
Update:
I am no longer using retina 4" images, it is better to use Universal images or iPhone specific images available and let xCode do the scaling for you on the smaller devices.
来源:https://stackoverflow.com/questions/32681933/xcode-7-retina-4-assets