This is my code
var body: some View {
Form {
Section(header: Text("People")) {
ForEach(people) { person in
PersonListItem(data: .constant(person))
}
}
}.listStyle(InsetListStyle())
.toolbar {
NavigationLink(destination: NewPerson(personData: .constant(Person.empty))){
Image(systemName: "plus")
}
}
}
On running it shows The section "People" and it's contents. But doesn't show the plus sign on the toolbar. What am I missing?
CodePudding user response:
Wrapped your form with NavigationView
struct ContentView: View {
var body: some View {
NavigationView{ // Here
Form {
Section(header: Text("People")) {
ForEach(people) { person in
PersonListItem(data: .constant(person))
}
}
}.listStyle(InsetListStyle())
.toolbar {
NavigationLink(destination: NewPerson(personData: .constant(Person.empty))){
Image(systemName: "plus")
}
}.navigationBarTitleDisplayMode(.inline)
}
}
}