对不起我的劣质英语。 名为'A'的单元格包含subTableView;'A'是正常的,但subCell的frame.size总是(320,44)。 显示代码。UITableViewCell的宽度和高度始终为320和44
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellID = @"OrderViewControllerCellID";
OrderTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (nil == cell) {
cell = [[OrderTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
OrderCellModel* model = self.orderDataSourceArray[indexPath.row];
cell.model = model;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor = [UIColor yellowColor];
return cell;
}
“A'cell内容查看
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
_productsArray = [[NSMutableArray alloc] init];
_productsTableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
_productsTableView.delegate = self;
_productsTableView.dataSource = self;
[self.contentView addSubview:_productsTableView];
_productsTableView.scrollEnabled = NO;
}
return self;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellID = @"OrderTableViewSubCellID";
OrderSubTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[OrderSubTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
OrderProductModel* model = _productsArray[indexPath.row];
cell.model = model;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _productsArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return transForHeight(86.f);
}
谢谢你看我的问题。 我很抱歉我的小英文了。
是的。它总是返回单元格44的高度。如果你想改变然后实现heightforrowatindexpath方法。 –
我不认为_auto-layout_已经为您的单元格的内容视图正确设置;看到你的截图,似乎甚至没有设置_autoresize-mask_。 – holex