iosswiftswiftuiswiftui-navigationview

SwiftUI NavigationView content only visible in iPad sidebar


My app is working as expected across all iPhone models, but when running on iPad I notice that the my application content, which is wrapped within a NavigationView, only displays in the iPad's sidebar, and only after tapping the 'Back` toolbar button.

var body: some View {
        NavigationView{
            ZStack{

        ...

        }
         .navigationBarTitleDisplayMode(.inline)
         .toolbar {
                ToolbarItem(placement: .principal) {
                    VStack {
                        Text("Add Light to Your Journey")
                            .font(Font.custom("EduTASBeginner-Regular", size: 24))
                        ...
    }
}

I found a similar question on SO that suggested adding the attribute .navigationViewStyle(.stack), but this did not change the way the app is displayed on iPad:

iPad

Note the solution on this similar post also did not resolve the issue.


Solution

  • As noted in the comments on the linked post, the .navigationViewStyle(StackNavigationViewStyle()) must be applied directly to the NavigationView, and not a view contained therein as with .navigationTitle