Alert controller description message are not multiline , it get truncated tail.?

Ask A Question

Login To post a question

I’m using the alert controller (NSMutableAttributedString for title and message) to display an alert, but my message gets truncated at it’s not multiline.
So anyway to multiline the message or I may need to changes any property for that please suggest.
The message comes from a server that’s why it isn’t possible to add the n.

Please post any solution.
Thanks in advance!

I just make normal demo it works perfectly, but I don’t know why it will be not working in my project code?

Here is my code:

    self.navigationController?.navigationBar.isHidden = true
    let alrtTitleStr = NSMutableAttributedString(string:"Title message which will from server")
    alrtTitleStr.addAttribute(NSAttributedStringKey.font, value: UIFont.boldSystemFont(ofSize: 18.0) , range: NSRange(location: 0, length: alrtTitleStr.length))

    let alrtMessage = NSMutableAttributedString(string:"Here is the message which comes from server and it should be display in muultiline.")
    alrtMessage.addAttribute(NSAttributedStringKey.font, value:  UIFont.systemFont(ofSize:16.0) , range: NSRange(location: 0, length: alrtMessage.length))

    let alertController = UIAlertController(title: "", message: "", preferredStyle: .alert)
    alertController.setValue(alrtTitleStr, forKey: "attributedTitle")
    alertController.setValue(alrtMessage, forKey: "attributedMessage")

    let btnYes = UIAlertAction(title: "Yes", style: .default, handler: { action in
       //next process
    let btnNo = UIAlertAction(title: "No", style: .default, handler: { action in
        //next process

    self.present(alertController, animated: true, completion: nil)

For more info please click here

Have a question or need a custom quote?