3

Is there a way to format the message (not the title) string of a UIAlertController to show multiple lines? I've tried the "/n" character and that doesn't work. I also can't use NSString and formatting it.

Thanks!

Edit: d'oh it should have been \n not /n. Here's the correct code

let alertController = UIAlertController(title: "blah", message: "1. blah \n2. blah \n3. blah", preferredStyle: .actionSheet)
Jason
  • 445
  • 1
  • 6
  • 16

1 Answers1

9

It will work with \n as edited.

let alert = UIAlertController(title: "Title",
                              message: "message: \n message",
                              preferredStyle: UIAlertControllerStyle.alert)

let cancelAction = UIAlertAction(title: "OK",
                                 style: .cancel, handler: nil)

alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
Fangming
  • 24,551
  • 6
  • 100
  • 90
PK86
  • 1,218
  • 2
  • 14
  • 25
  • How to handle if you receive from some webservices ? Please checkout this question. https://stackoverflow.com/questions/46212166/all-the-alert-dialog-message-and-textfield-have-been-changed-to-single-line-ple – jazzbpn Dec 21 '17 at 09:53