UITableCell 自定义单元格不占用自定义单元格的高度 [英] UITableCell Custom Cell not taking height of custom cell

查看:57
本文介绍了UITableCell 自定义单元格不占用自定义单元格的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续我的最后一个问题 UITableViewCell 自定义单元格使用IB 加载数据 可能最好为一个新问题开始一个新的!

A follow on to my last question UITableViewCell custom cell using IB loading data probably best to start a new one for a new question!

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

My Custom cell is loading (designed in IB)

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

Here is my xib file for the custom cell:

这是它如何加载到我的表中:

And heres how it loads in my table:

因此它不会加载自定义单元格的大小属性(而是将文本加载到右侧标签,并从笔尖加载右侧的蓝色箭头)

So it's not loading the size properties for the custom cell (but it's loading the text to the right labels and it's loading the blue arrow on the right from the nib)

以下代码是如何填充表格的:

Heres how the code is populating the table:

- (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;
}

我在加载单元格时做错了什么?

What am I doing wrong loading the cell?

汤姆

推荐答案

tableView:heightForRowAtIndexPath: 你可能需要这个方法(UITableView 的委托方法).
只需返回您想要的高度.或者通过indexPath判断不同类型的cell.

tableView:heightForRowAtIndexPath: You may need this method(UITableView's delegate method).
Just return the height you want. Or judge for different type of cell by indexPath.

这篇关于UITableCell 自定义单元格不占用自定义单元格的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆