UITextView如何截断文字 [英] UITextView how to cut off text

查看:54
本文介绍了UITextView如何截断文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView,它显示从Facebook Connect加载的Facebook状态.我正在尝试使UITextView只是创建文本的预览.我希望它看起来像UILabel的文本过多时的样子.带有圆点的文本可能会类似于文本太多...",但UITextViews不会这样做.有人知道如何使它工作吗?

I have a UITextView that is displaying a facebook status loaded from Facebook Connect. I'm trying to make it so that the UITextView is just creating a preview of the text. I want it to look like it does when there is too much text for a UILabel. It would be something like "There is too much text..." with the dots but UITextViews don't do that. Does anybody know how to get it to work?

推荐答案

编写一个单独的方法,该方法计算字符串中有多少个字母,如果有多个预设值,则将其剪切并在末尾附加三个点

Write a separate method that counts how many letters there are in the string and if there are more than some preset value then cut it and append three dots to the end.

此外,如果您不需要在内部编辑信息,请考虑使用UILabels而不是UITextViews,因为UITextViews需要更长的分配和初始化时间,并且通常比UILabels慢.

Also, consider using UILabels instead of UITextViews if you don't need to edit information inside since UITextViews take longer to allocate and init and are generally slower than UILabels.

这篇关于UITextView如何截断文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆