4

In Xcode 11 initial window is configured now in SceneDelegate, here my code and result on picture:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

     print("Scene willConnectTo.")
       guard let windowScene = (scene as? UIWindowScene) else { return }

    //  window =  UIWindow(frame: windowScene.coordinateSpace.bounds)
    window =  self.window ?? UIWindow()
     let mainView = ViewController()
    mainView.title = "TEST"
     let navigationController = UINavigationController()
    navigationController.viewControllers = [mainView]
    window?.backgroundColor = .red 
    window?.windowScene = windowScene
    window?.rootViewController = navigationController
    window?.makeKeyAndVisible()
}

Can anyone suggest how to make view covering all screen ?

enter image description here

Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
KirillC
  • 780
  • 2
  • 8
  • 21
  • This code is working just fine in my simulator. No black lines on iPhone 8/11 Pro. What are your constraints for the view in ViewController? And can you tell me if replacing it with UIViewController() changes anything for you? – Parth Nov 16 '19 at 16:42
  • Don't have any constraints in VC, it's programmatic if replace with UIViewController it works but I need custom – KirillC Nov 16 '19 at 16:57
  • I understand. I tried with a custom VC and it worked. Can you show your VC code? Especially code for the content that you are adding in self.view of your VC. – Parth Nov 16 '19 at 16:58
  • VC is empty, just blank template. – KirillC Nov 16 '19 at 17:23
  • Can you add a view to it? And make it stretch to all 4 sides? Like let contentView = UIView() view.addSubview(contentView) contentView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ contentView.leftAnchor.constraint(equalTo: view.leftAnchor), contentView.topAnchor.constraint(equalTo: view.topAnchor), contentView.bottomAnchor.constraint(equalTo: view.bottomAnchor), contentView.rightAnchor.constraint(equalTo: view.rightAnchor) ]) – Parth Nov 16 '19 at 17:28

2 Answers2

5

Make sure you have a LaunchScreen storyboard.

user1664112
  • 105
  • 7
0

It seems that its not possible to do LaunchScreen programmatically, as the screen will be loaded by the OS before the app launch itself, refer here

Dan
  • 810
  • 2
  • 11
  • 29