With the following code, Useless View
is shown on app startup for iPads in portrait mode. One press of the Back button results in the detail view showing "Link 1 destination". Only upon the second press is the sidebar shown. This is not the behavior we'd want for pretty much any app.
If we remove the Useless View from the code, we get a blank screen upon startup and we still have to press the back button once to get to the Link 1 destination, and twice to get to the sidebar. Also, the styling of the list in the sidebar appears less desirable.
The behavior we want is Link 1 destination shown on app startup and a single press of the Back button bringing us to the sidebar. Is this completely standard behavior that we'd expect for any app even possible with SwiftUI 3?
struct ContentView: View {
@State var selection: Int? = 0
var body: some View {
NavigationView {
List {
NavigationLink("Link 1", tag: 0, selection: $selection) {
Text("Link 1 destination")
}
NavigationLink("Link 2", tag: 1, selection: $selection) {
Text("Link 2 destination")
}
}
//If we delete the Useless View, we still have to press Back twice
//to get to the sidebar nav.
Text("Useless View")
.padding()
}
}
}