5

Ive been following this tutorial https://www.youtube.com/watch?v=_36Y6rDcKP0 on using Image.xcassets to display full screen images on different devices. Creating launch items is very easy as placeHolders are clearly displayed. But, my problem is when creating a new Image set as follows.

enter image description here

The images I have placed in each placeHolder is as follows:

  • 1x bg.png (320 x 640)
  • 2x bg@2x.png (640 x 960)
  • Retina 4 2x bg-568h@2x.png (640 x 1136)
  • 3x bg@3x.png (2208 x 1242)

My problem is when i run the IPhone 6 simulator it loads the bg@2x.png (640 x 960) image instead of the the bg-568h@2x.png (640 x 1136) image for IPhone 6? (the image is stretched). All other images sizes are correct for each device. On the video tutorial the the IPhone 6 simulator does load the bg-568h@2x.png (640 x 1136). What am I doing wrong ??

pete
  • 2,980
  • 4
  • 22
  • 34

4 Answers4

1

After a lot of playing around I believe this is a bug. When running iPhone 6, your Image.xcassets should load 568h@2x.png (640 x 1136). Xcode should scale this up to 750 X 1334. But it doesn't, it always loads the iPhone 4 (320 x 640) image. To work round this problem I have created two sets of Image.xcassets (Device Specific) as follows:

   - backGround.xcassets
   - 1x  (320 x 640)
   - 2x  (640 x 960)
   - 3x  (2208 x 1242)
   - //(uncheck 4- Retina)


   - backGroundRetina.xcassets
   - 2x  (640 x 1136)
   - //(only iPhone checked)

In (void)viewDidLoad {

 if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ){

    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    if( screenHeight < screenWidth ){
        screenHeight = screenWidth;
    }

   if ( screenHeight > 480 && screenHeight < 736 ){
        NSLog(@"RUNNING IPHONE 5 or 6");
          [_backGround setImage:[UIImage imageNamed:@"backGroundRetina"]];


   } else  NSLog(@"THIS IS NOT IPHONE 6");

      //  [_backGround setImage:[UIImage imageNamed:@"backGround"]]; will be called


}

Im sure there are other ways to solve this problem but this is whats working for me and I hope it helps other people stuck with the same problem.

pete
  • 2,980
  • 4
  • 22
  • 34
1

Someone commented in another question similar to this to add a Launch Screen File. After trying basically everything I added a Launch Screen File and everything worked. It's in the same place as where you set App Icons and Launch Images in the project file.

enter image description here

According to Apple, "You use a launch XIB or storyboard file to indicate that your app runs on iPhone 6 Plus or iPhone 6." I'm assuming this is what causes it to start pulling the correct images otherwise it doesn't treat it as the correct phone.

Tony
  • 798
  • 7
  • 9
0

@3x is for iPhone6 + and bg-568@2x is for retina4 Try with bg-667@2x

Hope it helps!

Vincent
  • 188
  • 5
  • No problem with the IPhone 6 plus. My problem is with the iPhone 6. I believe it should display the bg-568h@2x.png (640 x 1136) image not the 2x bg@2x.png (640 x 960)image – pete Oct 21 '14 at 20:36
  • iPhone 6 resolution is 750 X 1334 and should be named bg-667@2x. – Vincent Oct 21 '14 at 20:41
  • Thanks for your help but its made no difference. My images now look as follows 1x bg.png (320 x 640) 2x bg@2x.png (640 x 960) Retina 4 2x bg-667@2x (750 X 1334) 3x bg@3x.png (2208 x 1242). When I run the app with the iPhone 6 simulator it still runs the bg@2x.png (640 x 960) image. Have you got any other ideas ?? – pete Oct 21 '14 at 20:59
-1

the 2x images are being stretched to accommodate the increases screen size, If you use separate 3x images for icons and splash screens, the images are not stretched ad appear correctly

for greater detail... iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development

Community
  • 1
  • 1