UITableView高度自适应
来源:互联网 发布:软件售卖平台 编辑:程序博客网 时间:2024/05/01 04:53
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {// 列宽CGFloat contentWidth = self.tableView.frame.size.width;// 用何种字体进行显示UIFont *font = [UIFont systemFontOfSize:13];NSString *content = [data objectAtIndex:indexPath.row];CGSize size = [content sizeWithFont:font constrainedToSize:CGSizeMake(contentWidth, 1000) lineBreakMode:UILineBreakModeWordWrap];return size.height; }// Customize the appearance of table view cells.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; // 列宽CGFloat contentWidth = self.tableView.frame.size.width;UIFont *font = [UIFont systemFontOfSize:13];NSString *content = [data objectAtIndex:indexPath.row];// 计算出显示完内容需要的最小尺寸CGSize size = [content sizeWithFont:font constrainedToSize:CGSizeMake(contentWidth, 1000) lineBreakMode:UILineBreakModeWordWrap];// 構建顯示行 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; }CGRect rect = [cell.textLabel textRectForBounds:cell.textLabel.frame limitedToNumberOfLines:0];rect.size = size;cell.textLabel.frame = rect; cell.textLabel.text = content;cell.textLabel.numberOfLines = 0;cell.textLabel.font = font; return cell;}
0 0
- UItableView cell 自适应高度
- UItableview自适应高度
- UITableView高度自适应
- UITableview 的自适应高度
- uitableView高度自适应
- UITableView高度自适应
- UITableView 高度动态自适应 iphone
- UITableView 高度动态自适应 iphone
- iPhone UItableView cell 自适应高度
- swift UITableView cell自适应高度
- swift UITableView cell自适应高度
- UITableView的cell自适应高度
- UITableView的图片自适应高度
- UITableView的cell自适应高度
- UITableView 行自适应高度的实现
- UITableView 行自适应高度的实现
- UITableView 行自适应高度的实现
- UITableView 行自适应高度的实现
- 第七周 2
- 漫谈程序员系列:程序员零门槛?
- 论证是一门学问 如何让你的观点有说服力-4 规则4 具体、简明
- 作业:输入圆柱的半径R和高H,输出圆柱体的表面积S(电脑截图)
- 442 - Matrix Chain Multiplication
- UITableView高度自适应
- Ubuntu中文输入法IBUS的安装
- HDOJ 5062 Beautiful Palindrome Number
- Idea 12&13 注册码生成器
- 软件web测试之url测试(含POST 、GET)
- 第七周项目3
- 将一个字符串按单词逆序
- Android开发之播放器中涉及的Surface,SurfaceView,SurfaceHolder基础
- json_encode 中文乱码的解决方法