Post

Replies

Boosts

Views

Activity

Reply to Opening a sheet/modal after tapping on a SwiftUI List item in iOS 14+
Same situation here. I have an app I've been targeting for iOS 13, but just started testing on iOS 14 and most of my sheets no longer work like they continue to do on iOS 13 with the same code. One interesting thing I noticed when debugging is that my View's @State variables were wrong when I went to render the sheet (via a breakpoint in the .sheet {} code). The situation I saw this happen is when I have a List that presents a selected item on tap, like this: @State showDetailView: Bool = false @State selectedEntry: MyEntry = nil var entries: [MyEntry] func handleTap(_ entry: MyEntry) { 		self.selectedEntry = entry 		self.showDetailView = true } // omitted the 'body' declaration for brevity List { 		ForEach(self.entries) { entry in 				SomeCustomView(entry: entry).onTapGesture { 						self.handleTap(entry)	// this sets a couple @State variables that used to render the sheet 				} 		} } .sheet(isPresented: self.$showDetailView) { 		// Placing breakpoint on the next line reveals that self.selectedEntry is nil, 		// as well as other state variables (not show) are not reflected accurately 		if self.selectedEntry != nil { 				MyDetailView(entry: self.selectedEntry) 		} else { 				Text("Some Error State goes here")		 		} }
Aug ’20