iOS开发之tableViewCell高度自适应
来源:互联网 发布:sql count用法详解 编辑:程序博客网 时间:2024/05/20 20:45
设置model类Student
-(void)configureCellForModel:(Student*)stu
{
self.nameLabel.text= stu.name;
self.phoneNumberlabel.text= stu.phoneNumber;
self.hobbyLabel.text= stu.hobby;
//设置可以分行
self.hobbyLabel.numberOfLines= 0 ;
设置hobby的frame,自适应高度
self.hobbyLabel.frame=CGRectMake(110,90, 120,[BoyCellheightForString:stu.hobby]);
self.pictureView.image= [UIImageimageNamed:@"1.jpg"];
}
//在返回Cell高度时该方法需要使用+号方法。原因是:程序运行heightForRowAtIndexPath方法要比CellForRowAtIndexPath方法先执行。这时根本不存在Cell对象,所以只能用类名调用,使用加好方法
+(CGFloat)heightForRow:(Student*)stu
{
return [selfheightForString:stu.hobby]+ 90;
}
根据输入的字体大小和label的宽度,返回高度
+(CGFloat)heightForString:(NSString*)string
{
NSDictionary * dic =[NSDictionarydictionaryWithObject:[UIFontsystemFontOfSize:18]forKey:NSFontAttributeName];
CGRect bounds =[stringboundingRectWithSize:CGSizeMake(120,0)options:(NSStringDrawingUsesLineFragmentOrigin)attributes:diccontext:nil];
returnbounds.size.height;
}
- iOS开发之tableViewCell高度自适应
- [iOS] TableViewCell 自适应高度
- iOS之如何自适应TableViewCell的高度
- iOS之如何自适应TableViewCell的高度
- iOS tableviewcell 高度自适应方法
- IOS-根据TableviewCell 总体高度 做自适应
- IOS TableViewCell嵌套webview 自适应高度
- iOS开发UITableView篇:iOS 10.3 TableViewCell Label无法自适应高度
- IOS 开发之 cell高度自适应
- tableViewCell 自适应高度
- 自适应tableViewCell的高度
- tableViewcell高度自适应
- tableViewcell高度自适应
- TableViewCell自适应高度
- tableViewCell自适应高度
- TableViewCell高度的自适应
- TableviewCell高度自适应
- ios 7 自定义tableviewcell中的lable自适应高度
- 浏览器兼容笔记(2)
- Oracle常用命令大全
- 山东省第一届ACM大学生程序设计竞赛 Phone Number 字典树
- git命令总结
- js获取Url中参数值
- iOS开发之tableViewCell高度自适应
- C语言经典小程序(热门题型)
- android 自动初始化控件 不用注解不用findViewByid
- 百度地图为啥定位不了
- 支持向量机—线性可分支持向量机与硬间隔最大化
- 第四周项目3①-小学生算术能力测试系统
- CF_6D_LizardsAndBasements_2
- STM32 串口采用DMA方式收发
- GDAL库进度信息编写示例