Reputation: 356
I'm creating a menubar only application to scratch an itch of mine and I'm running into an issue using navigation stack and the toolbar to add a "add" button.
var body: some View {
VStack(alignment: .leading){
NavigationStack{
List(projects){ project in
NavigationLink(destination: ProjectDetailView(project: project)){
Text(project.name)
}
}
.navigationTitle("Projects")
.toolbar{
ToolbarItem(placement: .navigation, content: { Button(
action: {AddProject()},
label: {
Image(systemName: "plus").imageScale(.large)
}
)
}
)
}
}
}.frame(width: 400,height:600)
}
I tried using it outside the VStack as well with same result.
The navigation title and button show up fine in preview mode. But when I run the application only the title shows up. The button is not there. Also note if I click on a navigation link the toolbar has the back button.
Wondering if this is a bug or anyone come across this situation?
Upvotes: 1
Views: 240