Iphone 自定义UITableViewCell使用IB大小调整构建?
我已确保我的单元格的自动调整大小掩码允许灵活的宽度,但当设备旋转时,单元格不会调整大小 我还验证了tableview的大小,问题直接出在单元格上 这是我用来创建单元格的代码:Iphone 自定义UITableViewCell使用IB大小调整构建?,iphone,ipad,uitableview,autosize,Iphone,Ipad,Uitableview,Autosize,我已确保我的单元格的自动调整大小掩码允许灵活的宽度,但当设备旋转时,单元格不会调整大小 我还验证了tableview的大小,问题直接出在单元格上 这是我用来创建单元格的代码: if (cell == nil) { // Load the top-level objects from the custom cell XIB. NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MetaTa
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创建的单元格是否从未调整过大小?如果我理解您的问题,您想更改UITableViewCells的高度,对吗?尝试在TableView的委托中添加此行:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return *height*;
}
我也有同样的问题。如果您以IB设置大小,您可以在其中放入更多内容,但加载时它仍会询问您的学员高度。如果您的代理未实现此方法,它将只采用默认高度。如果是未调整大小的单元格高度,我建议您在旋转后修改
UITableView
代理方法
-
请确保您调用
[tableView reloadData]代码>当发生旋转时。您确定是单元格本身没有调整大小吗;与单元格中的某些内容相反?我通过从单元格中删除所有内容并显示来测试这一点。它仍然无法调整大小。如果单元格中没有任何内容,您如何知道单元格的位置?这些是分组的还是普通的?据我所知,你永远无法控制表格单元格的宽度;不管表格本身是什么,isI测试都只需要单元格上的标签,我在更改宽度时遇到了问题。
(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(condition)// has rotation taken place
// new height
else
// old height
}