2

I am currently working with the SwiftUI NavigationView on the iPad.

Problem: Obviously iPadOS supports 2 or 3 columns NavigationViews. However, I have to declare the number of Columns when initializing the NavigationView without any chance of changing this later.

My Idea (Does not work):

@State var selection: NavigationItem? = .first

NavigationView {
    sidebar

    Text("Select an Option in the left Sidebar.")

    if (selection == .first) {
        Text("Choose an Element to preview it here.")
    }
}

The NavigationView on the iPad will always be a 3 Columns One, although I only pass the third Text when the Selection == .first.

Screenshot of the iPad Screen

Question: How can I accomplish the Goal of having a NavigationView, which Number of Columns depend on the selected Option in the Sidebar. For Example, when selecting the First Option, I would like to have a 3 Column NavigationView while having a 2 Column One when the Second Option is selected?

Thanks for your help.

christophriepe
  • 1,157
  • 12
  • 47

0 Answers0