0

There is a weird issue for the iOS simulator to test iOS 7.1 and iOS 8.2 environment. When I try to get the screen size for iPhone 5s, the result is different. is this the bug in simulator? or is this the difference between iOS 7 and iOS 8?

Many thanks for any advice.

My code:

override func viewDidLoad() {
    super.viewDidLoad()

    println("Screen bounds: \(UIScreen.mainScreen().bounds)")

The iPhone 5s (8.2) simulator prints the result:

Screen bounds: (0.0,0.0,320.0,568.0)


The iPhone 5s (7.1) simulator prints the result:

Screen bounds: (0.0,0.0,320.0,480.0)

And there are top and bottom black bands to occupy the simulator iOS 7.1 screen.

Quill
  • 2,729
  • 1
  • 33
  • 44
  • On iOS 8.x , UIScreen.mainScreen().nativeBounds has been introduced. Take a look on it – David Ansermot Apr 30 '15 at 13:49
  • I think `nativeBounds` in iOS8 is just the same as `bounds` in previous iOS versions since `bounds` in iOS8 is orientation related. However, `nativeBounds` seems not contributing to the weird behavior here. What about other apps running in the 7.1 simulator? If the top & bottom black bands still exist I guess most probably it's a bug of the simulator. Otherwise you may want to check the configs of your app for iOS7.1. – Jinghan Wang Apr 30 '15 at 17:03
  • I would suggest you to use a splash screen & then run your code. After using the splash this black bank problem will be solved & you will get correct height as well. – iYoung May 02 '15 at 18:05

2 Answers2

1

The iPhone 5s has a 640x1136 pixel display which is 2x retina and thus 320x568 points.

Your 320x480 results as well as the existence of the letterboxing are consistent with an application running in compatibility mode on an iPhone5s as that matches the size of the older screens.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • Hi Jeremy, Could you give me a further explaination? where to find the existence of the letterboxing for the compatibility mode? – Roger Zhang May 03 '15 at 12:58
  • The compatibility mode is provided by UIKit for applications that were designed for older devices than it is currently running on (eg: apps for the smaller screens of older iPhones when running on newer iPhones or on iPads). The system will letterbox them to maintain accurate aspect ratio with the author's original intent. In your case, the system thinks that your application is not optimized for iPhone 5-sized devices. – Jeremy Huddleston Sequoia May 04 '15 at 01:00
0

Thats because in iOS 8 screen size is becoming orientation dependent please check this thread iOS screen size becoming orientation dependent

Community
  • 1
  • 1
hariszaman
  • 8,202
  • 2
  • 40
  • 59