2017-07-05 7 views
0

複数の行を表示するために、UIAlertControllerのメッセージ(タイトルではない)文字列をフォーマットする方法はありますか?私は "/ n"文字を試しましたが、それは動作しません。 NSStringを使用してフォーマットすることもできません。複数行のUIAlertControllerメッセージ

ありがとうございます!

編集:これは\ nではない/ nだったはずです。正しいコードは次のとおりです

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

「/ n」ではなく「/ n」です。そしてあなたの質問を関連するコードで編集してください。 – rmaddy

+0

コードを追加できますか? – PK86

答えて

3

編集後は\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) 
+0

いくつかのWebサービスから受け取った場合の対処方法を教えてください。この質問をチェックアウトしてください。 https://stackoverflow.com/questions/46212166/all-the-alert-dialog-message-and-textfield-have-been-changed-to-single-line-ple – jazzbpn

関連する問題