iphone - 使用 IB 调整大小构建自定义 UITableViewCell?

标签 iphone ipad uitableview autosize

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

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

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

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 创建的单元格是否从未调整过大小?

最佳答案

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

-

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

请确保在旋转发生时调用[tableView reloadData];

关于iphone - 使用 IB 调整大小构建自定义 UITableViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5332136/

相关文章:

iphone - UICollectionView:以编程方式查看标题

CSS :hover in Safari on iPhone and iPad clashes with added classes on click

iphone - 子类 UITableView 来更改部分索引的字体颜色?

ios - 对于大滚动区域,使 UITableView 单元格的宽度小于 UITableView

iphone - ALAssetLibrary 和 iOS 5.0

ios - 滚动在 iPhone 上不起作用

iphone - 在 iPhone 编程中追加到 NSString 中间

iphone - 更改 iPad 方向时 Xcode 4.5 出现问题

iphone - 将基于标签栏的 iPhone 项目迁移到 iPad

ios - 滚动到顶部,显示估计的单元高度