Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 not displaying correct image size for iPhone 6 simulator

Tags:

xcode

ios

iphone

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 ??

like image 522
pete Avatar asked Nov 11 '22 00:11

pete


1 Answers

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.

like image 59
pete Avatar answered Nov 26 '22 10:11

pete