2

if I have an app with some master/detail view with the following code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            NavigationLink(destination: DetailView()) {
                Text("Go to details")
            }
        }
    }
}

struct DetailView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
    }
}

The problem here is, that I want that also on the iPad the user first need to see the master page and not directly the detail view. But by default if you start the app it looks like this:

enter image description here

How to keep the master view open when the app starts on the iPad?

gurehbgui
  • 14,236
  • 32
  • 106
  • 178

1 Answers1

0

You could check the device type, if it's .pad then you show the master page:

if UIDevice.current.userInterfaceIdiom == .pad{
//Show master page
}