ios Tableview行高的计算
2016-09-16 16:21
369 查看
一、正常计算行高
这其中需要先传入一个最大尺寸和一个属性字典,特殊的格式要求都写在属性字典中。
二、预估行高
iOS8的新特性
需要适配iOS7的行高计算
三、系统自动计算
iOS 6.0以后都支持
这其中需要先传入一个最大尺寸和一个属性字典,特殊的格式要求都写在属性字典中。
NSDictionary *attrs = @{NSFontAttributeName : font}; [str boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size
二、预估行高
iOS8的新特性
需要适配iOS7的行高计算
_tableView.estimatedRowHeight = 30; _tableView.rowHeight = UITableViewAutomaticDimension;
三、系统自动计算
iOS 6.0以后都支持
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *identify = NSStringFromClass([Case8Cell class]); Case8Cell *cell = [tableView dequeueReusableCellWithIdentifier:identify]; if (!cell) { cell = [[Case8Cell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identify]; } Case8DataEntity *entity = _arrayEntity[indexPath.row]; [cell setEntityData:entity indexPath:indexPath click:^() { }]; //缓存行高 if (entity.cellHeight <= 0) { entity.cellHeight = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + 0.5f; } if (entity.cellHeight < 50) { return 50; } return entity.cellHeight; }
相关文章推荐
- ios-tableView自动计算行高
- iOS tableView三种计算动态行高方法
- ios-tableView的行高计算
- ios开发日记11 对tableView三种计算动态行高方法的分析
- ios tableview 自动计算cell高度
- IOS TableView代理设置 table的行高
- 对tableView三种计算动态行高方法的分析
- iOS tableView自动行高
- tableView计算动态行高的总结
- 对tableView三种计算动态行高方法的分析
- tableView计算动态行高的总结
- tableView三种计算动态行高方法
- iOS tableView 数据处理,数据分类相同数据整合、合并计算总数总价
- 动态的计算行高 加载数据源 有多少显示多少 tableView 包含 colloctionView 显示复杂的界面写法
- tableView计算行高的方法中,怎么让…
- Swift iOS tableView static cell动态计算高度
- 对tableView三种计算动态行高方法的分析
- iOS tableView自动行高
- 对tableView三种计算动态行高方法的分析
- Swift iOS tableView static cell动态计算高度