ChallengerGuy
ChallengerGuy

Reputation: 2395

UIAlertController and stacked UIAlert Buttons

I have an Xcode project programmed in Swift. I have an alert variable:

enter image description here

I also have the actual code for when the alert appears:

enter image description here

When I click on the 'Yes' button, everything resets and I can play the game again. enter image description here

If I want to play again and win, the alert now has stacked buttons.
enter image description here

How do I get rid of that and make it appear like the first time?

Upvotes: 2

Views: 3468

Answers (1)

clearlight
clearlight

Reputation: 12615

Don't keep adding new actions to your alert box.

Either create a new alert box, or use a flag to indicate you've already created the options, so you don't add them again.

It's turning into the vertical list ("Action Sheet") format, because it now thinks there are four entries and there's not enough room to add them horizontally. But two of them have blank labels, because it's not letting you duplicate the text, to avoid ambiguity for the end user.

Upvotes: 3

Related Questions