Post

Replies

Boosts

Views

Activity

Reply to SwiftUI sheet automatically dismisses itself
I had the same issue and the below code solution worked for me. Basically, all I did was put the .onTapGesture code that enables the sheet to display below the sheet code instead of above it. I know this looks very similar to the problem statement, but maybe the difference was setting the variable to true instead instead of toggling it. Not 100% sure. At least for me, after I did that, the sheet didn't do the weird disappearance thing after I opened it the first time.          VStack(alignment: .center) {           Image(systemName: "info.circle")             .font(.system(size: 22))             .foregroundColor(.blue)             .sheet(isPresented: $showFoodDataSheet) {               FoodHistorySheet(foodRetriever: item, showFoodDataSheet: $showFoodDataSheet)             }             .onTapGesture {               showFoodDataSheet = true             }         }
Mar ’22