-1

I created a very simple UINavigationController app. Not use IB and only create two files AppDelegate.swift and ViewController.swift. But the results look very weird. Please check the attached image

I use XCode 10.2.1. The simulator's screens can't be filled fully and iphone8 simulator's status bar put the wrong place.

the screens can't be filled

AppDelegate.swift:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    self.window = UIWindow(frame: UIScreen.main.bounds)
    let homeVC = ViewController(nibName: nil, bundle: nil)
    homeVC.title = "HOME"

    let nav = UINavigationController(rootViewController: homeVC)
    self.window?.rootViewController = nav
    self.window?.makeKeyAndVisible()

    return true
}

ViewController.swift:

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor.yellow
    // Do any additional setup after loading the view.
}

What's wrong with me?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
EdwardH.
  • 21
  • 3

1 Answers1

0

This looks like a case of unoptimized app for iPhone X and others. How are you doing the launchscreen? Since I don't see a LaunchScreen.storyboard I assume you are using image assets. That is frowned upon because you would need to update your app once a new screen size is created.

TL:DR Use LaunchScreen.storybooard for Launch Screen File VS Launch Images Source

EDITED: Create a LaunchScreen.storyboard and set it to Launch Screen file

enter image description here

  • I don't use launchScreen.storyboard or launch image. I deleted all storyboard files and completely use code to build the example – EdwardH. May 03 '19 at 03:23
  • See, image attached. You NEED to have a LaunchScreen (either via images or storyboard). Since you deleted all files, you would have a warning regarding this (as seen by the yellow triangle at the right side of run bar. – Joshua Francis Roman May 03 '19 at 03:25
  • I see. all ios app needs a lauchScreen. After I add the launch screen in info.plist. The result looks correct. Thanks Joshua – EdwardH. May 03 '19 at 03:37