NavigationView only shows Back button in SwiftUI

Viewed 577

I just create a swiftUI project and type this code on CntentView.swift. But the result is this image below. It was the same when I tried to run it on a real machine. Why?

NavigationView only shows Back button

Environment: Xcode Version 12.2(12B45b),


This is code of "Test13App.swift". Not edited any line. enter image description here


Thank you very much for your comments. Since I only have iPad pro (and not have iPhone), I just knew this is a default behaviour of iPad split view now by your comments. Adding .navigationViewStyle(DefaultNavigationViewStyle()) right after NavigationView solved the problem like this SwiftUI NavigationView on the iPad Pro

Sorry and Thanks very much!

2 Answers

If you want to change the style of your NavigationView on iPad making it similar to iPhone, you could use the:

.navigationViewStyle(StackNavigationViewStyle())

option in your NavigationView.

Like this:

struct ContentView: View {
    var body: some View {
        NavigationView{
            Text("prova")
        }
        .navigationViewStyle(StackNavigationViewStyle())
    }
}
Related