Search code examples
swiftxcodestoryboardios-simulator

View does not cover full screen when Xcode with Swift without storyboard


I am creating an app without storyboard; I removed the storyboard file. The app runs fine, but the output from the simulator is off; somehow I am not able to use the full screen of the iPhone.

iPhone simulator example where top and bottom is blank:
Iphone simulator example where top and bot is blank

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions){
guard let windowScene = (scene as? UIWindowScene) else { return }
    window = UIWindow(frame: UIScreen.main.bounds)
    window?.rootViewController = myViewController
    window?.makeKeyAndVisible()
    window?.windowScene = windowScene
}

What is missing here?


Solution

  • I have come across the same problem when the LaunchScreen.storyboard file was removed. Now the system seems not sure of the screen size and hence the problem occurs. Please try adding the LaunchScreen.storyboard if you have removed it.