shshsh12
shshsh12

Reputation: 135

NavigationView only shows Back button in 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!

Upvotes: 3

Views: 993

Answers (2)

Rahul Jamba
Rahul Jamba

Reputation: 11

When focused on both iPhone and iPad devices some developer's missing set the navigationview style type.

Set the NavigationView Style

Upvotes: 0

Valerio Ventucci
Valerio Ventucci

Reputation: 77

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())
    }
}

Upvotes: 4

Related Questions