Post

Replies

Boosts

Views

Activity

Reply to Opening a sheet/modal after tapping on a SwiftUI List item in iOS 14+
I ran into the same issue as well. The following has worked well for me, though not necessarily ideal: Set a variable equal to your @State variable in the body, but before the return, then read from that variable within .sheet. Works in Xcode 12.0 both in the canvas preview, and on a physical device running iOS 14.0. struct SwiftUIView: View { @State var showSheet = false @State var sheetType: SignInSheetType = .none var body: some View { let localSheetType: SignInSheetType = self.sheetType return Button(action: { self.showSheet = true self.sheetType = .generalHelp }) { Text("Hello, World!") } .sheet(isPresented: self.$showSheet) { if localSheetType == .generalHelp { SafariView(url: URL(string: "\(urlHere)")!) } else if localSheetType == .invite { SafariView(url: URL(string: "\(url2Here)")!) } } } }
Sep ’20