How to give each tab within swift UI modal a title

157 Views Asked by At

I have built a popup view with two tabs, each containing a form. I want to give each form a title and all the online documentation points to wrapping each form within a NavigationView and using .navigationBarTitle("Form Title"). However, when I build this for the iPad it ends up with back button to get to the form within the tab. Such as this:

enter image description here

and this:

enter image description here

var body: some View {
    NavigationView {
        Form {
                
            Section(header: Text("Question")) {

                TextField("Question Title", text: $title)
                TextField("Question Detail", text: $detail)
                TextField("Word Count", text: $wordCount)
            }

            Section {
                Button("Save") {
                let newQuestion = ApplicationQuestion(context: self.moc)
                    newQuestion.title = self.title
                    newQuestion.detail = self.detail
                    newQuestion.wordCount = self.wordCount

                    try? self.moc.save()
                    self.presentationMode.wrappedValue.dismiss()

                }
            }
        }
    }
    .navigationBarTitle("Full Screen")
    
}

What is the correct way of implementing this?

1

There are 1 best solutions below

1
the.blaggy On

You have to apply the navigationBarTitle modifier to the view inside of the NavigationView. In this example to the Form itself.