SwiftUI Navigation on iPad - How to show master list

后端 未结 3 1015
误落风尘
误落风尘 2020-12-31 01:31

My app has simple navigation needs

  • List View (parent objects)
  • List View (child objects)
  • Detail View (child object)

I have this

3条回答
  •  长情又很酷
    2020-12-31 02:06

    There also is a quite hacky workaround (see https://stackoverflow.com/a/57215664/3187762)

    By adding .padding() to the NavigationView it seems to achieve the behaviour of always display the Master.

    NavigationView {
            MyMasterView()
            DetailsView()
     }.navigationViewStyle(DoubleColumnNavigationViewStyle())
      .padding()
    

    Not sure if it is intended though. Might break in the future (works using Xcode 11.0, in simulator on iOS 13.0 and device with 13.1.2).

    You should not rely on it. This comment seems to be the better answer: https://stackoverflow.com/a/57919024/3187762

提交回复
热议问题