Xcode 6.1 using the same 2x image for iPhone 6 and 4s simulator

I am using the Object Catalog for images. My app contains full text tutorial pages. There are 4 versions for one image object for iPhone in images.xcassets section. 1x, 2x, Retina 4 2x and 3x.

I am using Xcode 6.1. When the app is run on the 4s simulator, it uses the 2x version of the image. The same image is used for the iPhone 6 simulator. Whether I set the deployment target to 7.1, 8.0, or 8.1, the same thing happens.

I have attached a test project explaining the problem. If you run the project in the simulator, the iPhone 4s and iPhone 6 show a 2x version image.

https://www.dropbox.com/s/8gon4czetkya485/AssetCatalogTest.zip?dl=0

How can I easily show a different image for 4s and 6 using the asset catalog?

+2


source to share


4 answers


There seems to be no way around this. I tried to duplicate the rules from the launch image and the asset directory dumps the images using the 667h and 736h subtypes used by the launch images.

You think it will work, but it doesn't:

{
  "images" : [
    {
      "idiom" : "iphone",
      "scale" : "2x",
      "filename" : "4.png"
    },
    {
      "idiom" : "iphone",
      "filename" : "6.png",
      "subtype" : "667h",
      "scale" : "2x"
    }
  ]
}

      



Your best approach is the old fashioned way. Create images for each size with names like test-667 and do something like:

[UIImage imageNamed:[NSString stringWithFormat:@"test-%g", [[UIScreen mainScreen] bounds].size.height]]

      

+1


source


Unfortunately, we have to be more careful with the documentation.

The subtype

option is only available for Startup Type , not for any other Image Set Type .

Please see these two links for confirmation:



Image Set Type

Run Image Type

+1


source


The reason is related to iPhone 4s / 5 / 5S and 6 using 2x times. Where, like 6 Plus, the 3x version will be used.

0


source


I had the same problem with full screen images. But I didn't find anything suitable, so I wrote a category that fixes this problem. You can find it on github . It uses the old-fashioned method of creating multiple images in this app bundle, but allows you to set different images for different idioms, orientations, and screens.

0


source







All Articles