syedfa syedfa - 1 year ago 52
iOS Question

Can a toolbar be added to a UIAlertController, as well as buttons to the rows using Swift?

I have a custom subView that was built using a

file in order to act as a
(which I know has been deprecated in favour of
). The subView looks like this:

enter image description here

What I would like to do is rebuild this subView as a
. My question is, can a
be added to the top of the
as in the image below, and can buttons be added to either side of each row for each option (the +/- signs are buttons). I am not interested in doing a redesign, however, I would like to re-implement this using a
with the same functionality. Is this possible? Are there any examples? Just wondering.

Thanks in advance to all who reply.

Answer Source

The short answer is - No.
As per UIAlertController Class Reference - you can only add a text field to an alert.

func addTextFieldWithConfigurationHandler(_ configurationHandler: ((UITextField) -> Void)?)  

Calling this method adds an editable text field to the alert. You can call this method more than once to add additional text fields. The text fields are stacked in the resulting alert.