Xcode 6 does not display the correct image size for iPhone 6 simulator

I read this tutorial https://www.youtube.com/watch?v=_36Y6rDcKP0 when using Image.xcassets to display full screen images on different devices. Creating launchers is very easy as placeHolders shortcuts are displayed on the screen. But, my problem is to create a new set of images as follows.

enter image description here

The images that I posted in each place are stored 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 that when I launch the IPhone 6 simulator, it uploads the bg@2x.png image (640 x 960) instead of the bg-568h@2x.png image (640 x 1136) for IPhone 6? (image is stretched). All other image sizes are correct for each device. In the video tutorial, the iPhone 6 simulator downloads bg-568h@2x.png (640 x 1136). What am I doing wrong?

+5
source share
4 answers

After many games, I think this is a mistake. When working with iPhone 6, your Image.xcassets must upload 568h@2x.png (640 x 1136). Xcode should scale to 750 X 1334. But this is not so, it always downloads an iPhone 4 image (320 x 640). To get around this problem, I 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 } 

I am sure that there are other ways to solve this problem, but this is what works for me, and I hope that it helps other people to depend on the same problem.

+1
source

Someone commented on another question like this to add a startup screen file. After trying basically everything that I added to the startup screen file, everything worked. It is located in the same place where you install application icons and launch images in the project file.

enter image description here

According to Apple : "You are using the starter XIB or storyboard file to indicate that your application is running on iPhone 6 Plus or iPhone 6." I guess this is what makes him start drawing the right images, otherwise he won’t see him as the right phone.

+1
source

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

Hope this helps!

0
source

2x images are stretched to increase screen size. If you use separate 3x images for icons and screensavers, the images are not stretched, the advertisement displays correctly.

for more details ... iPhone 6 Plus resolution issue: Xcode or Apple website? for development

-1
source

Source: https://habr.com/ru/post/1205225/


All Articles