UITableCell自定义单元格不占用自定义单元格的高度

时间:2011-11-23 13:54:45

标签: iphone ios uitableview

关注我的上一个问题UITableViewCell custom cell using IB loading data可能最好为一个新问题开始一个新问题!

我的自定义单元格正在加载(在IB中设计)

这是自定义单元格的xib文件:

enter image description here

以下是我在桌子上加载的方式:

enter image description here

所以它没有加载自定义单元格的大小属性(但它正在将文本加载到右侧标签,并且它正在从笔尖右侧加载蓝色箭头)

下面是代码如何填充表:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    ViewRoutesCell * aCell = (ViewRoutesCell *)[tableView dequeueReusableCellWithIdentifier:@"ViewRoutesCell"];

    if (aCell == nil)
    {


        NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"ViewRoutesCell" owner:self options:nil];

        for (NSObject *anObj in arr) {

            if([anObj isKindOfClass:[ViewRoutesCell class]]) {
                aCell = (ViewRoutesCell *)anObj;
                aCell.lblRouteText.text = [arryRouteText objectAtIndex:indexPath.row];
                aCell.lblRouteImage.text = [arryRouteImage objectAtIndex:indexPath.row];
            }



        }
}

    return aCell;
}

加载细胞我做错了什么?

汤姆

1 个答案:

答案 0 :(得分:3)

tableView:heightForRowAtIndexPath:您可能需要此方法(UITableView的委托方法) 只需返回您想要的高度。或者通过indexPath判断不同类型的细胞。

相关问题