I have 2 Alerts in 1 view like so (These alerts do work individually), But when combining 2 alerts into the 1 view its only showing alert 2.
I have read that you need to have these attached to different view.
So I have attached the 1 alert to the button
and 1 alert to the containing VStack
. Still only the second alert is showing. I trying to get both alerts to work.
var body: some View {
ScrollView {
VStack (alignment: .leading) {
...some stuff
VStack {
Button(action: {
dosomestuff
showingIntrestedAlert.toggle()
}) {
Text("Press Me")
}.alert(isPresented: $showingIntrestedAlert) {
Alert(title: Text("alert1"), message: Text("showing alert 1"), dismissButton: .default(Text("OK")))
}
}
}
.alert(isPresented: $fromViewModel.alreadyLikedUser) {
Alert(title: Text("alert2"), message: Text("alert 2 shown"), dismissButton: .default(Text("OK")))
}
}
}