Adding a line break to a UITextView

Mark Cicero picture Mark Cicero · Sep 13, 2010 · Viewed 97.3k times · Source

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?

Answer

imti picture imti · Mar 8, 2015

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.enter image description here