如何让 UITextView 尊重 Interface Builder 中的换行符?
我有一个简单的应用程序,其中将 UITextView
嵌入到 UIScrollView
中。 Interface Builder 不允许我添加多个换行符作为间距; 当我按回车键时,它会将其视为“输入结束”,而不是将换行符附加到 UITextView 中。
我怎样才能让它接受换行符作为间距?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
比以前的答案简单得多(并且更多基于 IB):
只需 Alt + ENTER 它将向
UITextView
发送换行符。Much simpler (and more IB based) than previous answers:
Just Alt + ENTER It will send a newline to the
UITextView
.在 TextEdit 中编写文本,然后复制/粘贴。
Write up your text in TextEdit, then copy/paste it in.
正如 sbwoodside 所说,文本编辑器是最简单的方法。
也就是说,如果您需要更多控制,或者它不太有效,请不要使用 IB。 理想情况下,如果您需要对长文本进行任何类型的格式化,请以编程方式进行。
IB 中的格式化非常糟糕。 我尝试在 UITextView 中添加一些“条款和条件”,这真的很痛苦。
到最后,这比搞IB容易多了……
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...
在 IB 中 Shift+Alt (Option)+Enter 是新段落
In IB Shift+Alt (Option)+Enter is as New paragraph