Post

Replies

Boosts

Views

Activity

Which is already presenting occurs when another View is presented while the Menu is displayed in SwiftUI.
Certainly, here's an explanation and the minimal code to reproduce the issue in English: In SwiftUI, attempting to present a sheet or any other presentation view while a Menu view is open causes a conflict. This is because SwiftUI does not allow multiple presentation views to be open at the same time. Here's the simplest code to reproduce the issue: import SwiftUI struct ContentView: View { @State var showSheet = false var body: some View { VStack { Menu { Button("Option 1") { } Button("Option 2") { } } label: { Text("Open Menu") } Button(action: { showSheet = true }) { Text("Open Sheet") } .sheet(isPresented: $showSheet) { Text("Hello, Sheet!") } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
2
1
1.3k
Jun ’23