Screen scale/size is right in iOS 8 but wrong in iOS 9 on same device - ios

I've recently updated Xcode to 7 so I could start developing against iOS 9. Upon first launching my application, I noticed that the screen size/scale is off compared to how it looks on iOS 8, both on the iPhone 6 device.
Here is how it looks correct on iOS 8:
Here is how it looks incorrect on iOS 9:
If you also notice, both of those images are the same exact size.
Note how the AdMob banner has white space on the left/right, I'm assuming AdMob just knows to center it. Also the big white space to the right of the table view and the button down on the bottom.
Also, when in iOS 8, and putting a break point in the main delegate method, the main window has a frame of (0 0; 320 568). The layer on the window is also the same.
On the flip side, when in iOS 9, and putting a break point in the main delegate method, the main window has a frame of (0 0; 375 667). The layer on the window is also the same.
That explains why the difference in the look of the app in iOS 8 vs. iOS 9, but I do not know why iOS 8 looks the way I want it to and iOS 9 doesn't. Is there some setting that I'm missing?
EDIT:
I've also since figured out that the bounds of the mainScreen is different between when this runs in iOS 8 vs. iOS 9. The screenBounds of the mainScreen is set to the same frame as up above, and I have no clue why it is different between the two iOS versions.
EDIT 2:
So I just created a brand new project and tested this out. I do not get the same behavior as explained up above in my first edit. When I view the mainScreen bounds, in both iOS 8 and iOS 9, it is (0,0;375,667);
I just cannot figure out what is causing this to happen so I can fix it.
EDIT 3:
After toying around quite a bit last night, it turns out that the launch images are causing this to happen. If I remove the launch images of Default-568#2x.png from the list, then it displays properly. Very odd that something like this can effect the scale. I still didn't figure out how to solve this yet though because you have to have launch images or apple will reject the app, so I'm keeping this open until I have more time tonight to toy around with it.

Are you testing on devices or simulators? If on device, your iOS 8 device might have Display Zoom enabled: Settings → Display & Brightness → Display Zoom. This would make an iPhone 6 (375 ✕ 667) think it’s an iPhone 5 (320 ✕ 568).

Apple has always looked at features of your application to decide what screen sizes your app can handle, and simulated a screen size that it is sure your app can cope with.
For example, you have probably added a launchscreen image in 320 x 568 pixels. That tells iOS that you know about 4" devices; without that your app would run in a 320 x 480 screen. To support an iPhone 6, you would have had to add a 375 x 667 launch screen; without it iOS reports that you have only an iPhone 5 sized screen.
Now you are using the iOS 9 SDK. When you use that SDK Apple expects you to handle any screen size, so suddenly it reports the true screen size of 375 x 667 (414 x 736 on a 6+). You can't use hardcoded sizes anymore; you have to adapt your app to the screen bounds.

Related

Different app resolution between iPhone 8 and iPhone 6,7 with same settings

we are developing an app that get images (640x480) from the rear camera and process it. Preview and images are displaced to top and right of the screen on the iPhone 8, but on iPhone 7 works perfectly as we want. We think the problem could be the values of focal length (fh,fv) set. As we know iPhone 7 & 8 has the same model of cameras and screen, but the response is different with the same settings. Any of you had the same problem or know how solve it?.
iPhone 8 incorrect behaviour (displaced at right and top).
https://imgur.com/a/tjt7btb
Correct beahaviour, centered in the middle of the screen (iPhone 7).
https://imgur.com/a/JkkCPJ9
Thanks in advance!.

Is it okay to leave out unnecessary launch images?

I have an app that supports only iPhones running iOS 10 or above.
I added only the following images:
Default-568h#2x.png
Default-667h#2x.png
Default-736h#3x.png
I left out:
landscape, since I assume iOS will use the portait one if landscape is missing.
iPad, since my app supports iPhone only.
3.5-inch iPhones, since I require iOS 10, which doesn't run on 3.5-inch iPhones.
Unfortunately, my UIWindow size is 320 x 658 points on the iPhone 7 Plus, rather than the 414 x 736 it should be. iOS thinks that I support only 4-inch screens, so renders my UI at that size and then expands it, making everything looks huge.
How do I fix this?
I'm not using storyboards or xibs. Please don't suggest that I use them. That's offtopic for this question.
When the above didn't work, I tried adding Default-Landscape-736h#3x.png, but it didn't help.
I also tried using an asset catalog, but that didn't work, either, as discussed in this separate question.
Launch images are about to be dropped completely. The only acceptable app submissions will be those with a launch storyboard. These rules are slated to go into effect in April 2020. So get ready now. See https://developer.apple.com/videos/play/wwdc2019/224/?time=103.

UI doesn't fill in iPhone 6 plus

I'm working on an iOS app and realize the ui is not auto stretch to fit the screen when it's running in iPhone 6 plus.
So the UI is on the right left, and there are a lot of white space in the bottom and right.
If I set the width of a view to beyond 320 (ex. 400), then the view be wider than 320.
How could I make my views auto stretch to fill the screen?
I have a few other apps, and they works perfectly fine in iPhone 6 plus.
I couldn't figure out what make this app's ui not auto stretching.
The only difference I could think of it this one is create after the official xcode 6 is released, the others were created in xcode 6 beta version
Thanks!
Seems like you enabled native resolution for iPhone 6 Plus. If you delete "launch screen file" you can individually control which screen size will be supported as native resolution by adding related size of launch images.
You should start using auto-layouts. Start from here: Auto layout guide

iOS 8 keyboard layout on iPhone 6/6 Plus

I noticed that on iOS 8, the native keyboard on iPhone 6/6 Plus added some keys in landscape mode.
However when I create an app with UITextView, the keyboard is same as iPhone 5 (without the function keys.) As the screenshot, you can see that the height of keyboards are not same, and the keys are different.
So, how do I change the keyboard appearance as the native one on iPhone 6/6 Plus?
You have to add special launch images for the iPhone 6 and 6 Plus to get the new keyboard layouts.
The reasoning behind this is that the phone runs your app in a special compatibility mode, that emulates a screen resolution of 320 points in width.
You can easily see, if your app runs in such a mode by outputting the screen resolution:
println("bounds = \(UIScreen.mainScreen().bounds)")
println("nativeBounds = \(UIScreen.mainScreen().nativeBounds)")
Without the designated launch images the output of the iPhone 6 Plus Simulator is:
bounds = (0.0,0.0,320.0,480.0)
nativeBounds = (0.0,0.0,960.0,1440.0)
And there will be no special keyboard
To get a comprehensive understanding of the new resolutions see this great blog entry: http://www.paintcodeapp.com/news/iphone-6-screens-demystified

How can I tell if a Springs and Struts app is scaling in the iPhone 6 simulator?

I have a couple applications built pre-auto-layout (but w/ Springs and Struts to support iPhone 5+) that I'm trying out in the iPhone 6 and 6 Plus simulator and they actually look quite good. However, I can't tell if the Springs and Struts are actually doing their job so-to-speak or if they're just being scaled. There must be some obvious thing I'm missing where it says which? Also, do auto-layout apps just automatically convert when recompiled with the latest SDK for iPhone 6 so they're not just scaling as long as 3X artwork is provided (in the case of 6 Plus)?
You can easily see, if your app runs in scaled mode by outputting the bounds and the native bounds screen of the main screen:
println("bounds = \(UIScreen.mainScreen().bounds)")
println("nativeBounds = \(UIScreen.mainScreen().nativeBounds)")
Without a designated launch images the output of the iPhone 6 Plus Simulator is:
bounds = (0.0,0.0,320.0,480.0)
nativeBounds = (0.0,0.0,960.0,1440.0)
The native bounds are 3 times the scaled bounds. This is the reason behind the #3x display.scale.
In case of the iPhone 6 Plus nativeScale also helps:
println("main screen native scale = \(UIScreen.mainScreen().nativeScale)")
println("main screen scale = \(UIScreen.mainScreen().scale)")
nativeScale will always be 3.0. scale will be 2.0 if the simulator does scaling.
To get a comprehensive understanding of the new resolutions see this great blog entry: http://www.paintcodeapp.com/news/iphone-6-screens-demystified
Use a different launch image for iPhone 6, iPhone 6 Plus and all the rest.
If you see a specific lunch image you know your app is not scaled and that it is running in the device's native resolution.
The only way I was able to tell was to go home and see if the status bar text was smaller than it was in my app. A smaller home screen status bar implies it is being scaled. If the status bar text is the same size within your app in the iPhone 6 sim as it is on the home screen of the simulator, then it is using your springs/struts or autolayout instead of scaling

Resources