我已确保单元格的自动调整大小蒙版允许灵活的宽度,但当设备旋转时,单元格的大小不会调整。
我还验证了表格 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/