Ios 表视图单元格的高度计算为零

Ios 表视图单元格的高度计算为零,ios,objective-c,uitableview,autolayout,heightforrowatindexpath,Ios,Objective C,Uitableview,Autolayout,Heightforrowatindexpath,我有一个UITableViewCells,由于某种原因,我的单元格的高度计算为零。 以下是我目前拥有的: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { id model = self.Model[indexPath.row]; if ([model isKindOfClass:[FR self]]) { ListTa

我有一个
UITableViewCell
s,由于某种原因,我的单元格的高度计算为零。

以下是我目前拥有的:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    id model = self.Model[indexPath.row];

    if ([model isKindOfClass:[FR self]]) {
        ListTableViewCell *cellOne = [tableView dequeueReusableCellWithIdentifier:@"1Cell" forIndexPath:indexPath];
        if (!cellOne) {
            cellOne = [[ListTableViewCell alloc] init];

            FR *fD = (FR *)model;
            NSString *title = [NSString stringWithFormat:@"%@", fD.title];
            NSString *dateString = [self timeSincePublished:fD.pubDate];
            NSString *description = [self removeHTMLTags:fD.description];
            NSString *link = [NSString stringWithFormat:@"%@", fD.link];

            cellOne.labelHeadline.text = title;
            cellOne.labelDescription.text = description;
            cellOne.labelPublished.text = dateString;
        }

        // Make sure the cell's frame is updated
        [cellOne setNeedsLayout];
        [cellOne layoutIfNeeded];

        CGFloat heightOne = [cellOne.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
        return heightOne + 2;

    } else if ([model isKindOfClass:[D self]]) {

    // more code
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    id model = self.Model[indexPath.row];

    if ([model isKindOfClass:[FR self]]) {

        FR *fD = (FR *)model;

        ListTableViewCell  *1Cell = [tableView dequeueReusableCellWithIdentifier:@"1Cell"];

        if (!1Cell) {
            1Cell = [[ListTableViewCell alloc] init];

            FR *fD = (FR *)model;
            NSString *title = [NSString stringWithFormat:@"%@", fD.title];
            NSString *dateString = [self timeSincePublished:fD.pubDate];
            NSString *description = [self removeHTMLTags:fD.description];

            1Cell.labelHeadline.text = title;
            1Cell.labelDescription.text = description;
            1Cell.labelPublished.text = dateString;

        }

        return 1Cell;

    }

    // more code
}
我不确定当我通过断点查看
heightOne
的值时,为什么
heightOne
返回零

我正在使用自动布局


有什么想法吗?谢谢如果需要,将发布额外代码,谢谢

为什么要用这种方法设置单元格变量?这应该在
cellforrowatinexpath:
方法中完成。你也检查过cellOne是否为零吗?是的,我也在
cellForRowAtIndexPath:
中做,我想我可以把它带出去。是的,
cellOne
不是零。当我尝试你的代码时,我在
dequeueReusableCellWithIdentifier:
处得到一个递归调用堆栈异常。你能通过你的
cellForRow
方法代码吗?你是如何在表视图中注册你的手机的?@sunkhappy当然,我在原来的问题中添加了代码,谢谢!