SwiftUI: unwanted split view on iPad

Update July 2022

Using NavigationStack instead of NavigationView should display as the main view as you would expect on iPad:

NavigationStack {
    Text("Hello world!")
}

*In newer versions, the navigationViewStyle modifier has been deprecated.

Original answer:

You can apply the .navigationViewStyle(.stack) modifier to the NavigationView.

... 
    NavigationView {
        Text("Hello world!")
    }
    .navigationViewStyle(.stack)
...

Edit: Below, I am answering Alexandre's questions from his comment:

  • Why full view is not the default for iPad? That's just a choice made by Apple...

  • Why this modifier goes outside of NavigationView closure, while the Navigation Title goes inside... Maybe this gives clarification: https://stackoverflow.com/a/57400873/11432719


To use this split style for iPad but remove for iPhone:

extension View{
    func phoneOnlyStackNavigationView() ->some View {
        if UIDevice.current.userInterfaceIdiom == .phone{
            return AnyView(self.navigationViewStyle(StackNavigationViewStyle()))
        } else {
            return AnyView(self)
        }
    }
}