我有一个需要传递一个信息给heightForRowAtIndexPath方法的自定义表视图细胞的方法。如何执行自定单元
每个单元格必须回答这个问题应该有heightForRowAtIndexPath方法是什么规模。 如何在特定的indexPath上引用该单元格并执行其getHeight方法?
我使用了[tableView dequeueReusableCellWithIdentifier:@"theCell" forIndexPath:indexPath];
但我得到错误:“警告:无法加载任何Objective-C类信息,这将显着降低可用类型信息的质量。”当我尝试去做它。
我应该改变我的做法还是有一个方法来“问”它应该有其尺寸电池?
这是我自定单元的getHeight方法
-(CGFloat)getHeight{
if(isCardOpen){
//Calculate the size it should have based on its sub products
//returning a test value for validation only
return 253;
}
return 153;
}
这是我heightForRowAtIndexPath
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
CardCell *cell = (CardCell*)[tableView dequeueReusableCellWithIdentifier:@"theCell" forIndexPath:indexPath];
return [cell getHeight];
}
我推荐你阅读这个:http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights – Koen