向 UITextView 添加换行符 [英] Adding a line break to a UITextView
问题描述
我有一个 UITextView
,它采用 NSString
格式,格式为 stringWithUTF8String
.它从数据库中获取它的值,我希望数据库中的文本在文本中使用中断来呈现.我尝试使用
来做到这一点,但它被呈现为文本.在我的应用程序信息页面中这样做是因为直接文本有效,但我认为从数据库中获取它时它不起作用的原因是格式.
有什么建议吗?
如果你想在 Xcode5/Xcode6 storyboard Attribute-Inspector (AI) 中添加换行符,你可以这样做:
- 拖出一个 UITextView.
- 双击它以编辑文本,将光标放在您想要分段符的位置.
- 按 alt-Enter 几次以创建一个空行 &段.
或者,CTRL + Return 换行.
您现在可以在故事板的输出/查看模式中看到效果.>
I have a UITextView
that takes an NSString
with formatting stringWithUTF8String
. It is getting its values from a database and I want the text in the database to be rendered with breaks within the text. I tried using
to do this but it gets rendered as text. Doing this in my information page of the app as straight text worked but I think the reason its not working when taking it from the database is because of the formatting.
Any suggestions?
If you want to add newline in Xcode5 / Xcode6 storyboard Attribute-Inspector (AI), you do it this way:
- Drag out a UITextView.
- Double-click it to edit text, place cursor where you want the paragraph break.
- Hit alt-Enter a couple of times to create a blank line & paragraph.
Or, CTRL + Return make a new line.
You can now see the effect into output / View-mode in storyboard.
这篇关于向 UITextView 添加换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!