IOS 动态改变cell的高度
来源:互联网 发布:shell编程的特点 编辑:程序博客网 时间:2024/05/02 01:17
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.tag = 1;
label.lineBreakMode=NSLineBreakByCharWrapping;
label.highlightedTextColor = [UIColor whiteColor];
label.numberOfLines = 0;
label.opaque = NO; // 选中Opaque表示视图后面的任何内容都不应该绘制
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
}
UILabel *label = (UILabel *)[cell viewWithTag:1];
NSString *text = [_dataList objectAtIndex:indexPath.row];;
CGRect cellFrame = [cell frame];
cellFrame.origin = CGPointMake(0, 0);
CGRect rect = CGRectInset(cellFrame, 2, 2);
label.frame = rect;
cellFrame.size.height = 50 + label.frame.size.height - 46;
}
else {
cellFrame.size.height = 50;
}
[cell setFrame:cellFrame];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
return cell.frame.size.height;
}
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.tag = 1;
label.lineBreakMode=NSLineBreakByCharWrapping;
label.highlightedTextColor = [UIColor whiteColor];
label.numberOfLines = 0;
label.opaque = NO; // 选中Opaque表示视图后面的任何内容都不应该绘制
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
}
UILabel *label = (UILabel *)[cell viewWithTag:1];
NSString *text = [_dataList objectAtIndex:indexPath.row];;
CGRect cellFrame = [cell frame];
cellFrame.origin = CGPointMake(0, 0);
CGRect rect = CGRectInset(cellFrame, 2, 2);
label.frame = rect;
[label sizeToFit];
label.text =[_dataList objectAtIndex:indexPath.row];
cellFrame.size.height = 50 + label.frame.size.height - 46;
}
else {
cellFrame.size.height = 50;
}
[cell setFrame:cellFrame];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
return cell.frame.size.height;
}
- IOS 动态改变cell的高度
- IOS 动态改变cell的高度
- iOS 动态改变cell的高度
- 动态改变CELL 的高度
- 动态改变tableview的cell的高度
- IOS 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- iOS 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- UITableView动态改变Cell高度
- UITableView动态改变Cell高度
- 【iOS知识学习】_iOS动态改变TableView Cell高度
- 【iOS知识学习】_iOS动态改变TableView Cell高度
- 【iOS知识学习】_iOS动态改变TableView Cell高度
- iOS开发-UI控件:动态改变UITableView中的Cell高度
- ios开发笔记之如何让tableView根据文本内容动态改变cell的高度
- 点击cell动态改变cell高度
- iOS开发动态计算cell的高度
- iOS开发动态计算cell的高度
- iOS开发动态计算cell的高度
- hibernate对象关系映射
- 托福评分标准
- 云存储——易盘
- Nova虚拟机的状态和转换
- 云存储——网易网盘
- IOS 动态改变cell的高度
- 为什么使用extern “C”?
- windows8应用《同济新闻客户端》隐私声明
- HDU 3555 Bomb (数位DP)
- JAVA编程思想笔记——初始化和清理(1)
- linux系统编程之文件与I/O(六):fcntl 函数与文件锁
- 关于Java性能的9个谬论
- Android SDK下载与在eclipse中的安装(菜鸟来讲超慢易理解版)
- Win7系统设置Wifi热点(非原创)