3

我已确保我的单元格的自动调整大小掩码允许灵活的宽度,但是当设备旋转时,单元格不会调整大小。

我还验证了 tableview 是否已调整大小,问题直接出在单元格上。

这是我用来创建单元格的代码:

if (cell == nil) {
        // Load the top-level objects from the custom cell XIB.
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MetaTableViewCell" owner:self options:nil];
        // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
        cell = [topLevelObjects objectAtIndex:0];
    }

有人能想到可能出了什么问题吗?

使用 IB 创建的单元格是否从未调整大小?

4

2 回答 2

1

如果它是未调整大小的单元格的高度,我建议您UITableView在旋转后修改委托方法。

-

(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(condition)// has rotation taken place
    // new height
    else
    // old height
    }

请确保您[tableView reloadData];在轮换发生时致电。

于 2011-03-18T09:09:44.173 回答
0

如果我理解你的问题,你想改变 UITableViewCells 的高度,对吧?尝试在 TableView 的委托中添加这一行:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return *height*;
}

我遇到了同样的问题。如果您在 IB 中设置大小,您可以在其中放置更多东西,但它仍然会在加载时询问您的委托人的高度。如果您的委托未实现此方法,它将仅采用默认高度。

于 2011-03-18T09:05:54.410 回答