-1

I have this iPhone app targeted to iOS 7.

I have created an entry on .xcassets called mainImage that is device specific for iPhones. So xcode presents me with 4 slots I have to fill with images. that has these images: 1x, 2x, Retina 4 2x and 3x.

I have filled each slot with the following images in order:

  1. 1x = 320 x 480 pixels image
  2. 2x = 750 x 1334 pixels image
  3. Retina 4 2x = 640 x 960 pixels image
  4. 3x = 1242 x 2208 pixels image

Then I have a viewController on storyboard that is adjusted with the iPhone 6 size and the imageView there is adjusted to load just "mainImage".

The image shown there is the iPhone 4 2x stretched, not the correct one. It should be showing the 750x1334 image.

If the imageView is adjusted with "mainImage", wasn't it supposed to load the correct image for the viewController size?

I run that on iPhone 6 and indeed the image shown is the iPhone 4 image stretched.

Anyway to fix that?

Duck
  • 34,902
  • 47
  • 248
  • 470
  • the iPhone6 has simple retina screen only (`@2x`), the iPhone6+ has the HD Retina screen (`@3x`), so obviously on the retina screen the retina image will be loaded. – holex Apr 27 '15 at 17:40
  • so? what sizes of images should I put in these 4 slots to make everything work correctly on the iPhone 4, 5, 6 and 6+? – Duck Apr 27 '15 at 17:43
  • There's plenty of existing questions regarding "Retina 4 2x" and iPhone 6, might want to put a bounty on one of them instead of creating a duplicate. – A-Live Apr 27 '15 at 18:01

3 Answers3

1

It does not work like that. You can have separate images for different screen densities, not for different screen sizes. You have to add a separate entry for each screen size and select the image yourself. Launch image is the only asset that works automatically with different screen sizes.

How to specify size for iPhone 6/7 customised edge-to-edge image?

Community
  • 1
  • 1
Tapani
  • 3,191
  • 1
  • 25
  • 41
0

In fact there is one more limitation/bug on xcassets, beyond the impossibility to localize it to different languages, that is the ability to load a different image or better the correct to iPhone 6. Apple did not realized that the way xcassets work now will not load the correct image if you care using full screen images.

The solution for that is not to use xcassets, create the images you need and a class to call the correct image based on the screen size/needs.

Duck
  • 34,902
  • 47
  • 248
  • 470