iPhone 处理tableview里面要显示的过长的文字
来源:互联网 发布:photoshop cs5 mac 编辑:程序博客网 时间:2024/05/21 04:20
NSString *setByTrcanateWithAttributeForWidth(NSString *s,NSDictionary *attr,float wid,NSLineBreakMode truncateMode)
{
NSSize textSize = [s sizeWithAttributes:attr];
if(textSize.width <= wid)
{
return s;
}
NSMutableString *currString = [NSMutableString string];
NSRange rangeToCut = {0,0};
if(truncateMode == NSLineBreakByTruncatingTail)
{
rangeToCut.location = [s length] - 1;
rangeToCut.length = 0;
}
else if(truncateMode == NSLineBreakByTruncatingHead)
{
rangeToCut.location = 0;
rangeToCut.length = 1;
}
else
{
rangeToCut.location = [s length]/2;
rangeToCut.length = 2;
}
while (textSize.width > wid)
{
if(truncateMode != NSLineBreakByTruncatingHead && rangeToCut.location <=1)
return @"....";
[currString setString: s];
[currString replaceCharactersInRange:rangeToCut withString:@"...."];
textSize =[currString sizeWithAttributes: attr];
rangeToCut.length++;
if(truncateMode == NSLineBreakByTruncatingTail)
{
rangeToCut.location--;
}
else if((rangeToCut.length && 1) != 1)
{
rangeToCut.location--;
}
else if((rangeToCut.location < 0) || (rangeToCut.location +rangeToCut.length) >[s length])
{
return @"....";
}
}
return currString;
}
- iPhone 处理tableview里面要显示的过长的文字
- 关于TableView中显示帮助文字的处理
- 文字过长,QLabel显示不全的问题
- UILabel文字过长时的显示格式
- UILabel文字过长时的显示方式
- IOS-TableView里面cell的显示动画
- Label显示数据过长的处理方式
- 【iOS】处理tableView上的文字
- TableView里面的cell根据图片或者文字自定义高度
- 解决select选项内容过长,文字显示不全的问题
- flex4解决label中文字过长显示省略号的办法
- flex4解决label中文字过长显示省略号的办法
- css实现文字过长显示省略号的方法
- UILabel标签文字过长时的显示方式
- 如何将<td>文字过长的部分变成省略号显示
- UILabel lineBreakMode:设置标签文字过长时的显示方式。
- 【Android】TextView当文字过长时的显示
- UILabel标签文字过长时的显示方式
- 成功升级到iOS5,给力啊!!有好多改进的地方!!
- RealV210开发板Cortex-A8内核Android2.3
- HttpHandler获得Session值失败问题解决方法
- javascript把输入的数字或字母变成****
- iPhone 4S全面评述(6):总结
- iPhone 处理tableview里面要显示的过长的文字
- 堆介绍
- 用VC纯资源dll制作多语言界面程序
- How to add customized button to SM30.
- iPhone 用UIGestureRecognizer侦测使用者输入操作
- ELF文件加载过程代码分析
- 嵌套repeater
- 网站更换域名后如何解决301重定向
- Tomcat报错:IOException+while+loading+persisted+sessions:+java.io.EOFException解决手记