3

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!

shshsh12
  • 125
  • 1
  • 1
  • 12
  • It doesn't look normal. Can you share the code in `Test13App.swift`? – Cuneyt Dec 07 '20 at 02:50
  • 1
    It is default navigation view style for iPad, split view - left sidebar is hidden. What did you expect? – Asperi Dec 07 '20 at 04:16
  • Thanks for help. I added the image of Test13App.swift. And , oh, this is the normal behavior of iPad split view...? I expect, a text shown in the middle of the screen on iPad too. – shshsh12 Dec 07 '20 at 04:22
  • Cuneyt, Asperi, Thank you! Solved the problem! I add .navigationViewStyle(StackNavigationStyle()) and working same as iPhone! – shshsh12 Dec 07 '20 at 04:34

2 Answers2

4

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

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

Set the NavigationView Style