UI_UItableView_AutoCell(自定义cell 高度)
来源:互联网 发布:js中name选择器 编辑:程序博客网 时间:2024/06/14 19:28
#pragma mark 赋值方法-(void)setCellDataWithModel:(NewsModel *)sender{ self.titleLabel.text = sender.title; self.summaryLabel.text = sender.summary; CGFloat height = [NewsCell getHeightWithModel:sender]; // 把计算出来的高度赋值给label CGRect labelFrame = self.summaryLabel.frame; labelFrame.size.height = height; self.summaryLabel.frame = labelFrame; }
#pragma mark - 计算高度的方法+ (CGFloat)getHeightWithModel:(NewsModel *)model{ // 计算高度 (summaryLabel) // 宽度,高度必须定死一个 NSDictionary *fontDic = @{NSFontAttributeName:[UIFont systemFontOfSize:17.0f]}; CGRect rectFrame = [model.summary boundingRectWithSize:(CGSizeMake([UIScreen mainScreen].bounds.size.width - 20, MAXFLOAT)) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:fontDic context:nil]; return rectFrame.size.height;}
#pragma mark - 计算 cell 高度+ (CGFloat)heightWithModel:(NewsModel *)model{ // 当做标记 opeModel = model; return [self getHeightWithModel:model] + 20 + 25;}
// 封装+ (instancetype)getCinemaCellWithTableView:(UITableView *)tableView{ static NSString *cell_id = @"CinemaCell"; CinemaCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_id]; // if (cell == nil) {// cell = [[CinemaCell alloc] initWithStyle:(UITableViewCellStyleSubtitle) reuseIdentifier:cell_id];// } return cell;}
#pragma mark - cell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row < 10) { CinemaCell *cell = [CinemaCell getCinemaCellWithTableView:tableView]; // 设置cell 的值 [cell setCellDateWithModal:self.dataArray[indexPath.row]]; return cell; } else { static NSString *cell_id1 = @"UITableViewCell"; CinemaCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_id1]; cell.textLabel.text = @"llldsoie"; return cell; } }
#pragma mark - cell 高度- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return [NewsCell heightWithModel:self.dataArray[indexPath.row]];}
0 0
- UI_UItableView_AutoCell(自定义cell 高度)
- UI_UItableView_AutoCell(自定义cell)
- 自定义cell的高度
- 自定义cell的高度
- xib 自定义cell高度
- xib自定义cell,返回cell高度
- iOS 自定义Cell 自适应高度
- iOS 自定义cell的高度
- UI 10 cell 自定义高度
- UI - TableView高级(自定义cell、cell自定义高度)
- UITableView-的cell 自定义 高度,样式
- 根据文字自定义Label和Cell高度
- 自定义cell的高度(新浪微博)
- 自定义cell高度实现简单通讯录
- sizeWithFont方法_自定义cell高度
- cell自定义方式一 高度一致时
- cell自定义方式二 高度不一致时
- Cell的自定义高度 图片 文本
- 每天小练笔8-模拟进程调度
- jdbc链接sqlserver数据库的问题
- NSArray, NSNumber, NSValue, NSSet, 数组排序
- XML Schema <第三篇>
- JavaWeb开发中form、ajax提交数据Model转化
- UI_UItableView_AutoCell(自定义cell 高度)
- oc知识点整理
- 关于类的关键词
- Hyperion 的oce创建
- Mac系统中强制删除废纸篓文件
- 栈的应用
- 最小值(划分树)
- Leetcode-Sudoku Solver
- 面向对象编程之异常处理