UITextView 添加文本到新行
我想向我的 iPhone 应用程序的 UITextView 添加新的文本行。基本上我的文本视图以一行开始,随着应用程序的进步,会添加新行。但是,我只能添加到现有文本的末尾或开头。我怎样才能将这样的条目放入新行中。我可以在计算的范围/位置手动发送 \n 到 textview.text 吗?
例如我的意思。 第 1 行:这是文本的第一行。这是第二个 第 2 行:文本行。 - -
我想: 第 1 行:这是文本的第一行。 第 2 行:这是文本的第二行。
谢谢!
I would like to add new lines of text to my UITextView for my iPhone app. Basically my textview starts with a single line, and as app advances, new lines are added. However I can add only to the end or beginning of the existing text. How can I make such an entry into a new line. Can I manually send \n to the textview.text at a calculated range/location.
E.g. of what I mean.
line 1: This is first line of text. This is second
line 2: line of text. ---
I want:
line 1: This is first line of text.
line 2: This is second line of text.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
-[NSString stringByReplacingCharactersInRange:withString:]
修改 UITextView 的文本。然后,您可以将该字符串指定为 UITextView 的新文本对象。You can use
-[NSString stringByReplacingCharactersInRange:withString:]
to modify the text of the UITextView. You can then assign that string as the new text object of the UITextView.