Hi,
I have a strange case involving sheets, which I think it's a bug, but then again I might be missing something.
Using the following code:
I would assume that, depending on which button is pressed, I would say a sheet with the text "whichSheet = one" or "whichSheet = two" etc.
But no matter which button is pressed first the text on the sheet is always "whichSheet = none". Only if you choose a different button the second (or third, or ...) time the correct text is being displayed.
Bug or am I missing something really obvious?
(Test using an iOS 14 / 14.2 project with Xcode 12 / 12.2 beta)
Cheers, Michael
I have a strange case involving sheets, which I think it's a bug, but then again I might be missing something.
Using the following code:
Code Block import SwiftUI enum WhichSheet: String { case one, two, three, none } struct ContentView: View { @State private var _showSheet = false @State private var _whichSheet: WhichSheet = .none var body: some View { VStack(spacing: 8) { Button("One Sheet", action: { self._whichSheet = .one; self._showSheet = true}) Button("Two Sheet", action: { self._whichSheet = .two; self._showSheet = true}) Button("Three Sheet", action: { self._whichSheet = .three; self._showSheet = true}) } .sheet(isPresented: $_showSheet, content: { Text("whichSheet = \(_whichSheet.rawValue)") }) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
I would assume that, depending on which button is pressed, I would say a sheet with the text "whichSheet = one" or "whichSheet = two" etc.
But no matter which button is pressed first the text on the sheet is always "whichSheet = none". Only if you choose a different button the second (or third, or ...) time the correct text is being displayed.
Bug or am I missing something really obvious?
(Test using an iOS 14 / 14.2 project with Xcode 12 / 12.2 beta)
Cheers, Michael