您的位置:首页 > 其它

cell单元格高度自适应

2015-07-19 13:50 288 查看


//接收字符串并计算出高度
+ (CGFloat)cellForHeight:(NSString *)content {

CGSize size = [content sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(KScreenWidth-92-14, 1000)];
return size.height + 60;
}

/**计算单元格行高*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_indexPathIndex == indexPath) {
commDataModel *model = self.data[indexPath.row];

CGFloat Hight = [CommTableViewCell cellWithHight:model.content];

if (Hight < 90) {

return 90;
}

return Hight;
}

return 80;

}

#pragma mark - 单元格点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
/**记录点击的单元格*/
_indexPathIndex = indexPath;

//[tableView reloadData];

[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: