UITableViewCell 中添加UIView uitableviewcelluiview 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 主要是动态高度的问题。需要自己计算,将计算后的高度在cellForRowAtIndexPath中设置成cell 的高度。按下面的步骤去做1. 在自定义的uiview中,公开一个内容高度的属性如contentHeight.这个属性你要在自定义的uiview中自己计算2. 在将这个view添加到cell上时,在cellForRowAtIndexPath 中在返回cell之前需要重置cell 的高度-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = .......; UIView *customView = .....; cell.addSubview(customView); //////重置cell的高度 CGRect currentCellFrame = cell.frame; currentCellFrame.size.height = customView.contentHeight; //////计算得到的实际高度 cell.frame = currentCellFrame; return cell;}3. 这一步也很关键,取cell的高度也是使用的协议方法,所以我们需要在这个协议方法中返回-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *) indexPath { UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath: indexPath]; return cell.frame.size.height; //////返回cell的实际高度} 我大概是这么做的,但是cell在滑动的时候,出现了卡顿的情况,锁业我在想怎么解决? 用fopen在mac os x下为什么没有效果? iphone公交搜索,支持全国各大城市 求SIM卡中EF(CHV)和MF/DF/EF的头结构 android真的不适合开发游戏吗? 关于UICollectionView的问题~ 调试查看变量问题 求移动开发书目表、工具表、硬件准备 跪求tableView手势冲突的解决方案 ASI的下载进度 iOS开发兼顾图像处理 NSMutableData接收完数据后,访问异常,大神指点! 手游消息包多大正好?
1. 在自定义的uiview中,公开一个内容高度的属性如contentHeight.这个属性你要在自定义的uiview中自己计算
2. 在将这个view添加到cell上时,在cellForRowAtIndexPath 中在返回cell之前需要重置cell 的高度
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = .......;
UIView *customView = .....;
cell.addSubview(customView); //////重置cell的高度
CGRect currentCellFrame = cell.frame;
currentCellFrame.size.height = customView.contentHeight; //////计算得到的实际高度
cell.frame = currentCellFrame;
return cell;
}3. 这一步也很关键,取cell的高度也是使用的协议方法,所以我们需要在这个协议方法中返回
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *) indexPath {
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath: indexPath];
return cell.frame.size.height; //////返回cell的实际高度
}