I noticed something weird: if I delete all launch images/storyboards from an iOS app project, then UIScreen.main.bounds
shrink to 320x480, regardless of an actual screen size.
My question is: do I need a launch image/storyboard to make sure that the size of the main screen is correct?
Here is a code sample:
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let screenBounds = UIScreen.main.bounds
print(String(describing: screenBounds)) // Prints "(0.0, 0.0, 320.0, 480.0)"
window = UIWindow(frame:screenBounds)
window!.rootViewController = MyViewController()
window!.makeKeyAndVisible()
return true
}
}
And here is my simulator's screen (iPhone 8 plus, iOS 11.2):
If you don't have any launch images, and you don't have a launch nib or storyboard, then you are declaring that you don't support any screen sizes aside from 320x480 (on iPhone/iPod).This has always been true but older Xcode Projects automatically generated a png to support 4" screens. This may have been invisible if you've used an iPhone 6 or iPhone 6 Plus, because if you had the default image for 4" screen support, these devices scaled your app rather than letter boxing them.
I assume the letter boxing is to ensure your UI won't get wrecked by iPhone X's top notch and became the new default behavior instead of scaling.
Adding launch images or storyboards to your project for the screen sizes you support should resolve this