向UITextView添加换行符 [英] Adding a line break to a UITextView
问题描述
我有一个UITextView
,它的NSString
格式为stringWithUTF8String
.它正在从数据库获取其值,并且我希望数据库中的文本在文本中带有断点.我尝试使用\n
来执行此操作,但是它被渲染为文本.在应用程序的信息页面上以纯文本方式执行此操作是可行的,但我认为从数据库中获取它时不起作用的原因是因为格式.
有什么建议吗?
如果要在Xcode5/Xcode6故事板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 \n
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屋!