|
Hi, the second alert works if the first is commented out but I cannot get them to work together. When showingScore is true and playAgain is true I expected the alerts to run one after the other but that is not the case. I've added some extra Text fields to my view so I can watch the two variables and they are changing from false to true as I would expect. showingScore is reset to false by the alert and even though playAgain is true the alert does not appear.
Any help appreciated. Regards |
|
@iwaddo - just attach the second alert to some other View, its an issue where two simultaneous alerts do not respond ... good luck |
|
|
|
hi, the placement of .alert() modifiers makes a lot of difference. i think this post by Sarun provides an explanation for presenting multiple alerts in the most common situations. if you need something more involved, you could look into using something like this is fairly generic:
where the definition of
and
any time you want to present an alert, you follow this sequence:
where however, that may be a little bit more than what you need. hope that helps, DMG |
|
Thank you, this is exactly what I need, different scenarios from a single alert modifier. I need a message and continue when showingScore is true and a different message with different buttons and actions when playAgain is true. I will give it a try. Thank you for your help |
|
There is also this way. By have one alert and passing in the error title and details depending on the error you want to show.
|
|
Have by playing around with Add a
Then when you want to call the alert have one
The advange of this is all alert detail are in one place and less in the |
|
Some hidden gems here, very informative indeed, this post is to be bookmarked .. thanks @NigelGee and @delawaremathguy |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.