pete
pete

Reputation: 3050

Xcode 6 not displaying correct image size for iPhone 6 simulator

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:

My problem is when i run the IPhone 6 simulator it loads the [email protected] (640 x 960) image instead of the the [email protected] (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 [email protected] (640 x 1136). What am I doing wrong ??

Upvotes: 5

Views: 4745

Answers (4)

Tony
Tony

Reputation: 848

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.

Upvotes: 1

pete
pete

Reputation: 3050

After a lot of playing around I believe this is a bug. When running iPhone 6, your Image.xcassets should load [email protected] (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.

Upvotes: 1

Kevin Ives
Kevin Ives

Reputation: 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

Upvotes: -1

Vincent
Vincent

Reputation: 188

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

Hope it helps!

Upvotes: 0

Related Questions