0

I have been searching for a long time and cannot find anything similar to this issue. I am new to SwiftUI and try to make a sample project.

When I launch my app, the view appears with black borders at top and bottom.

As I don't have a clue on what can go wrong, here is the SceneDelegate I have in my project.

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window : UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = scene as? UIWindowScene else { return }
        self.window = UIWindow(windowScene: windowScene)
        self.window?.frame = UIScreen.main.bounds
        let vc = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateInitialViewController()
        self.window!.rootViewController = vc
        self.window!.makeKeyAndVisible()
    }
}

I have a storyboard containing a single UIHostingController which is the entry point. Here is its implementation :

class HostingViewController: UIHostingController<Text> {

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder, rootView: Text("text"))
    }

}

Below is a screenshot of the simulator when the app runs.

I have tried to reduce as much as possible the amount of code in the project to identify the origin of the issue but unfortunately nothing is solving this issue.

enter image description here

As I don't know what could go wrong maybe the snippets I linked do not show the correct part of the code. Please feel free to ask for more information if needed.

Thanks in advance for any piece of advice you could provide.

Arthur
  • 390
  • 1
  • 4
  • 13
  • 3
    Make sure you have added a launch screen storyboard to your project. – Paulw11 Nov 18 '21 at 19:03
  • Wahou ! @Paulw11 Thank you so much ! It works like a charm ! Please, add an answer so I can accept it! (btw if you can explain why I would be happy to understand) Anyway you just saved me a huge amount of time THANKS :-) – Arthur Nov 18 '21 at 20:17
  • 1
    I'll find a duplicate somewhere and link it to that. Essentially way back when, apple introduced a phone with a bigger screen than the original iPhone. Apps hadn't been rebuilt to take advantage of that bigger screen so they ran "letterboxed" so that they would still look ok. The way apple detects if your app supports the bigger screen is to look for a launch image of the right size or a launch storyboard. Basically ios thought your app didn't support big screens – Paulw11 Nov 18 '21 at 20:45

0 Answers0