向UITextView添加换行符 [英] Adding a line break to a UITextView

查看:176
本文介绍了向UITextView添加换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView,它的NSString格式为stringWithUTF8String.它正在从数据库获取其值,并且我希望数据库中的文本在文本中带有断点.我尝试使用\n来执行此操作,但是它被渲染为文本.在应用程序的信息页面上以纯文本方式执行此操作是可行的,但我认为从数据库中获取它时不起作用的原因是因为格式.

有什么建议吗?

解决方案

如果要在Xcode5/Xcode6故事板Attribute-Inspector(AI)中添加换行符,请按照以下方式进行操作:

  1. 拖出一个UITextView.
  2. 双击它以编辑文本,将光标放在要断开段落的位置.
  3. 点击 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:

  1. Drag out a UITextView.
  2. Double-click it to edit text, place cursor where you want the paragraph break.
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆