- (CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath{
// NSLog(@”heightForRowAtIndexPath”);
// carCell cell = (carCell )self.protoTypeCell;
// carCell *cell = [carCell cellWithTableView:tableView indexPath:indexPath];
// cell.car = [self.cars objectAtIndex:indexPath.row];
// NSLog(@”%p”,cell);
// return [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
NSLog(@”%p”,self.protoTypeCell);
return [self.protoTypeCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;(用一个成员变量来记录cell ,避免在cellforrowatindexpath调用后,再调用heightforrowatindexpath时候再创建一个cell实例,浪费内存);
}
- (CGFloat)tableView:(UITableView )tableView estimatedHeightForRowAtIndexPath:(NSIndexPath )indexPath{
return 100;
}(初始化的时候 , 避免一下全部计算出cell 的高度)
如果想在UITableViewCell中点击的时候拿到点击了第几行,我们可以通过UITableViewCell.Tag 来拿到对应的。in indexPath.row.