Hi everybody !
When I have a NavigationView and I want to make appear the actionSheet popover on the navigationBarItem button it works.
But when I add a StackNavigationViewStyle it doesn't work anymore. This NavigationViewStyle break the actionSheet and it will not appear when I tap "+" button. I think there is a constraint problem in SwiftUI with ActionSheet and StackNavigationViewStyle in the NavigationView.
navigationViewStyle(StackNavigationViewStyle())
This is the complete code
struct ContentView: View {
@State private var showNewControlActionSheet = false
var body: some View {
NavigationView {
Text("test")
.navigationBarTitle("Test")
.navigationBarItems(trailing: HStack() {
Button(action: {
self.showNewControlActionSheet = true
}) {
HStack {
Image(systemName: "plus")
.padding(10)
.clipShape(Circle())
}
}
.actionSheet(isPresented: $showNewControlActionSheet) {
ActionSheet(title: Text("Change background"), message: Text("Select a new color"), buttons: [
.default(Text("Red")) { },
.default(Text("Green")) { },
.default(Text("Blue")) { },
.cancel()
])
}
})
}.navigationViewStyle(StackNavigationViewStyle())
}
}
It works very well on iPhone but NOT on iPAD