UITEXTVIEW-每行字符的限制数量
我有一个uitextView
,每次用户每行限制chars限制时,我都想划分(假设每行30个字符是最大的字符)。而且我也想保存单词包装,因此,如果单词中间达到了30个限制,则应该直接进入新行。
我应该如何解决这个问题?我希望有一个本机解决方案,但在文档中找不到任何相关的解决方案。
I have a UITextView
and I want to line break each time a user is extending a limit of chars per line (let's say 30 chars per line is the maximum). And I want to save the word wrapping too so if a 30 limit is reached in the middle of a word, it should just go straight to the new line.
How should I approach this problem? I was hoping for a native solution but can't find anything related in the documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
textViewDidchange
从uitextviewDelegate
使用textViewDidChange
委托方法来添加newline,每30个字符之后,您将需要此扩展名来split
string> string 在上述代码中相等的部分工作:
You can use this workaround by using
textViewDidChange
delegate method fromUITextViewDelegate
to add newline after every 30 characters, like thisYou will need this extension to split
String
in equal parts for above code to work though: