I've a simple question: How can I make the message of an UIAlertController be selectable and copyable by the user?
The controller is initiated like so:
let alertController = UIAlertController(title: "Hello World", message: "Copy Me!", preferredStyle: .Alert)
and displayed like so:
presentViewController(alertController, animated: true, completion: nil)
Adam's correct that UIAlertController doesn't provide text selection functionality, so a traditional copy/paste solution isn't going to work. You could alternatively provide a button on your UIAlertController
that copies a string to the pasteboard.
UIPasteboard.general.string = "Copy Me!"
It is not possible. UIAlertController
has no such functionality. It was implemented with UILabel
components, which don't support copying text. You are not allowed to subclass UIAlertController
either. The only option is to implement your own controller instead.
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