Hello all,
When I use Alert in SwiftUI, I realize that I can only show number of Alert less than or equal number of View. Example: I have a Button to show a random Alert: True Alert and False Alert. But only underneath Alert (False Alert) is shown and the above Alert (True Alert) is ignored:
struct ContentView: View {
@State var showTrueAlert = false
@State var showFalseAlert = false
var body: some View {
Button(action: {
let isTrue = Bool.random()
if isTrue {
self.showTrueAlert = true
print("True Alert")
} else {
self.showFalseAlert = true
print("False Alert")
}
}) {
Text("Random Alert")
.font(.largeTitle)
}
.alert(isPresented: $showTrueAlert) {
Alert(title: Text("True"))
}
.alert(isPresented: $showFalseAlert) {
Alert(title: Text("False"))
}
}
}
Is any one meet this problem? And can anyone can solve this