【问题标题】:Multiple lined UIAlertController message多行 UIAlertController 消息
【发布时间】:2017-07-05 23:42:57
【问题描述】:

有没有办法格式化 UIAlertController 的消息(不是标题)字符串以显示多行?我已经尝试过“/n”字符,但它不起作用。我也不能使用 NSString 和格式化它。

谢谢!

编辑:哦,应该是\n而不是/n。这是正确的代码

let alertController = UIAlertController(title: "blah", message: "1. blah \n2. blah \n3. blah", preferredStyle: .actionSheet)

【问题讨论】:

  • 这是\n,而不是/nedit 你的问题还有一些相关的代码。
  • 你能添加你的代码吗?

标签: ios swift uialertcontroller


【解决方案1】:

它将与编辑后的\n 一起使用。

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)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-23
  • 1970-01-01
  • 2017-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多