Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationView SwiftUI shows split view in iPad

With NavigationView being the root of UIHostingController , the below code shows split view for iPad.

struct ContentView: View {
    var body: some View {
        
        NavigationView {
            Text("Hello")
                .navigationBarTitle("Home")
        }
    }
}

With the above code it shows split view on iPad. How can I still use the NavigationView and get rid of split view for iPad , as I am looking to have a List and on tap of which it should push another view?

enter image description here enter image description here

like image 895
NNikN Avatar asked Jun 28 '20 15:06

NNikN


1 Answers

Use stack navigation view style explicitly (by default it is platform-dependent)

NavigationView {
   Text("Hello")
       .navigationBarTitle("Home")
}
.navigationViewStyle(StackNavigationViewStyle())
like image 171
Asperi Avatar answered Nov 08 '22 19:11

Asperi