I know you can disable UIAlertAction buttons in a UIAlertController, but is it possible to remove the button completely once it has been added?
It is not possible to remove actions from a UIAlertController
once added.
The actions
property can return an array of the added actions, but is a get
only and can not be set.
Actions are added with the addAction(_:)
method, but there is not a corresponding removeAction(_:)
method.
And ultimately, it doesn't really necessarily make a lot of sense to be removing actions from an alert controller once added. You generally should be reusing the alert controller object once instantiated, so the solution is to simply only added the appropriate actions in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With