NSString 格式问题
我有类似 "Circular Quay W, The Rocks NSW, Australia"
的 NSString,我想以以下字符串格式显示:
Circular Quay W,
The Rocks NSW,
Australia
所以请帮助我开发此功能。
提前致谢。
I have NSString like "Circular Quay W, The Rocks NSW, Australia"
and I want to display in following string format:
Circular Quay W,
The Rocks NSW,
Australia
so please help me to develop this functionality.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您在
UILabel
中显示字符串。不要忘记将标签的 numberOfLines 设置为 0。这使标签可以显示多行文本。
Assuming that you are displaying the string in a
UILabel
.Don't forget to set numberOfLines of the label to 0. This lets the label to show multiline text.
将每个逗号替换为(逗号和新行“,\n”),如果您在
UILabel
中显示它,请确保首先将高度和行数设置为 0< /strong> 使用属性numberOfLines
。replace each comma with (comma and new line ",\n"), if you're showing it in a
UILabel
make sure to set the height and the number of lines first to 0 using propertynumberOfLines
.这应该可以完成工作:
[NSString stringWithString:@"Circular Quay W,\n The Rocks NSW,\n Australia"];
干杯
This should do the job:
[NSString stringWithString:@"Circular Quay W,\n The Rocks NSW,\n Australia"];
Cheers