How to get UITextView to respect newlines in Inter

2019-01-17 03:19发布

问题:

I have a simple app with a UITextView embedded into a UIScrollView. Interface Builder won't let me add multiple newlines for spacing; when I hit return it sees that as "end of input" rather than appending the newline to the UITextView.

How can I get it to accept newlines for spacing?

回答1:

Much simpler (and more IB based) than previous answers:

Just Alt + ENTER It will send a newline to the UITextView.



回答2:

Write up your text in TextEdit, then copy/paste it in.



回答3:

As sbwoodside said, a text editor is the easiest way.

That said, ff you need more control, or it isn't quite working, don't use IB. Ideally, if you need any type of formatting for a long sting of text, do it programmatically.

Formatting in IB is horrible. I tried to add some "terms and conditions" in a UITextView and it was a real pain.

In the end it is easier than messing with IB...



回答4:

In IB Shift+Alt (Option)+Enter is as New paragraph