1
votes

I created an image for retina resolution for 4 inch screen with the size of 640x1136px. It didn't scale properly. To debug, I decided to let the code print out the width and height of self.view.frame. The results were

width: 320 height: 480

this is incorrect as height should be 568 points (1136 px). What is the deal with wrong frame size in objective-c spriteKit?

Edit:

Code posted below

Below @implementation

UIImageView* menuImage;

in (void)didMoveToView:(SKView *)view

menuImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"menuImage"]];
menuImage.frame = self.view.frame;
NSLog(@"height: %f || width: %f", self.view.frame.size.height, self.view.frame.size.width);

Edit 2:

submitting the results of few tests

ScreenSize: {{0, 0}, {320, 480}}
SuperViewSize: {{0, 0}, {0, 0}}
SelfSize: {{0, 0}, {320, 480}}
1
Are you sure you are not accidentally checking it on 3.5 device/simulator or manually changing the view size somewhere? - AMI289
Can you please add the following NSLog statements and post their values? NSLog(@"ScreenSize: %@", NSStringFromCGRect([[UIScreen mainScreen] bounds])); NSLog(@"SuperViewSize: %@", NSStringFromCGRect(self.view.superview.bounds)); NSLog(@"SelfSize: %@", NSStringFromCGRect(self.view.bounds)); - AMI289
Can you run it on a 4-inch simulator and see if you get the same results? - AMI289
Please try, on the 'Navigator' on the left side, go to 'Images.xcassets' -> 'LaunchImage' and make sure you have a 4-inch launch image. - AMI289
I agree it sound weird, but have a look here stackoverflow.com/questions/19353455/… - AMI289

1 Answers

0
votes

With the help of AMI289 (see comments), we figured out how to repair this.

First, I went to the project settings, and under General I removed the text from "Launch Screen File". Then, I added Launch Image Source. Afterwards, I removed the launch image set file and created new one. This made the menuImage fit the whole screen in correct resolution.

Note: This might work only when using launch image instead of launch file, since part of the process was to remove the text in launch screen file textfield. However, I'm not sure which part of the process actually fixed the problem so it might work anyway.