0

Here is the code I am using:

struct ContentView: View { @State var showingAlert: Bool = false var body: some View { VStack { Button("Show Alert") { showingAlert = true } } .alert(isPresented: $showingAlert) { Alert(title: Text("Important message"), message: Text("Wear sunscreen"), dismissButton: .default(Text("Got it!"))) } } } 

I tried tapping the Show Alert button so many times in the iPad Pro (11-inch) (3rd Generation) simulator but nothing happens. What's wrong in the code above? or is it a bug in the latest simulator? (I am using Xcode 12.5).

2
  • it’s working fine for me. Tested on IOS 14.5, iPad Pro (11-inch) 3rd generation and Xcode 12.5. Commented May 28, 2021 at 12:17
  • This is really weird. Another friend has it running too on the same settings. May be my Xcode version is corrupted. Commented May 28, 2021 at 12:53

1 Answer 1

2

As it turns out, I have an alert in the parent view. It seems it blocked the one in the child view. Once I removed the alert from the parent one, the child's alert appeared. Thanks, swiftUI, for being so smart.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.