Swift - Truncated text in UIAlertController

Hi Apple dev Team,

Alert view controller message text is truncated when the message contains URL strings. Please help me on this.

I am using below code please check and let me know if anything wrong with Alertview controller API's.  

`let urlString = "htttp://google.com"
   let message = "targ.et is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit Are you sure, you want to get redirected to arget is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit Are you sure, you want to get redirected to %@ ? \(urlString)"

   let noAction = UIAlertAction(title: "No", style: .cancel, handler: nil)
    showAlert(title: "Redirecting to external URL",
         msg: message,
         style: .alert,
         actions: nil)`

Replies

You haven't got any URL strings; you've got a String called urlString, and you're adding it into a very long message which is the same bit of text duplicated.

No wonder the message is truncated. Can you reduce the message? Maybe something like:

targ.et is not running or doesn't have entitlement 'com.apple.runningboard.assertions.webkit'. Are you sure, you want to redirect to %@ ?

It is not a URL question. Just too long a message. Also think of users, they usually don't appreciate so long messages.

But if you do need the complete text, you may:

  • create your own view that mimic the alert
  • you may try to use attributedString to reduce font size.

See here: