Post

Replies

Boosts

Views

Activity

Reply to SwiftUI sheet modifier with item binding crash when binding value changes
In my case first setting selected sheet value to nil and then to desired value inside Task did solved the problem: Task { self.sheet = nil self.sheet = .createNew } My guess is that assigning selected sheet directly causing the crash because the current sheet is still presented, Setting it to nil first resolves the problem. You could also try setting new value to sheet after delay that view needs to dismiss the current sheet. The code Could be something like that then: Task { await try Task.sleep(for: .seconds(0.3)) self.sheet = .createNew } or DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { self.sheet = .createNewTag }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to SwiftUI sheet modifier with item binding crash when binding value changes
In my case first setting selected sheet value to nil and then to desired value inside Task did solved the problem: Task { self.sheet = nil self.sheet = .createNew } My guess is that assigning selected sheet directly causing the crash because the current sheet is still presented, Setting it to nil first resolves the problem. You could also try setting new value to sheet after delay that view needs to dismiss the current sheet. The code Could be something like that then: Task { await try Task.sleep(for: .seconds(0.3)) self.sheet = .createNew } or DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { self.sheet = .createNewTag }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24