Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationView only shows Back button in SwiftUI

Tags:

swiftui

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!

like image 813
shshsh12 Avatar asked Dec 04 '25 17:12

shshsh12


1 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())
    }
}
like image 172
Valerio Ventucci Avatar answered Dec 06 '25 17:12

Valerio Ventucci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!