如果我的字符串在目标 c 中具有换行符,如何以正确的格式打印字符串
我对这段代码有疑问:
NSString *msg=[[TBXML valueOfAttributeNamed:@"msg" forElement:root] ];
lblText.text=msg;
变量 msg
包含字符串 “Good Job\nThanks”
。当我将“msg”分配给标签文本属性时,字符串显示为换行符 \n
但我希望字符串显示如下:
Good Job
Thanks
/shivam
I am having an issue with this piece of code:
NSString *msg=[[TBXML valueOfAttributeNamed:@"msg" forElement:root] ];
lblText.text=msg;
The variable msg
contains the string "Good Job\nThanks"
. When I assign 'msg' to the label text property, the string is shown with the newline character \n
but I would like the string to be displayed like this instead:
Good Job
Thanks
/shivam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您的字符串似乎来自 XML 文件,因此请尝试输入 XML 的换行符
而不是
\n
。否则,它将打印字符\
和n
。As your string seems to come from a XML file, try to enter the XML's New Line character
instead of
\n
. Otherwise it will print the characters\
andn
.尝试将标签的行数设置为无限数量:
Try to set number of lines that label could have to unlimited number: