When I run the following code on my iPad and select an item in the sidebar, the ToolbarItem button shows up, but when I go to the home screen and return to the app, the ToolbarItem button disappears.
struct ContentView: View {
@State var selection: Int? = nil
var body: some View {
NavigationSplitView {
List(selection: $selection) {
ForEach(0...10, id: \.self) { value in
NavigationLink(value: value) {
Text("\(value)")
}
}
}
} detail: {
ZStack {
Text("Select : \(selection ?? -1)")
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
} label: {
Text("ToolbarItem")
}
}
}
}
}
}