저는 autolayout을 사용하여 테이블 중 하나에서 heightForRowAtIndexPath
을 확인했습니다. 그것은 하나만 제외하고 모든 세포에서 작용합니다. 문제를 해결하기 위해 내가 찾아야 할 아이디어가 있습니까?셀 단일 셀에서 자동 레이아웃 셀 높이가 작동하지 않습니다.
높이를 올바르게 반환하지 않는 것은 HILargeMessageImageCell
입니다. 지금은 여기에 0을 반환 코드입니다 :
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell;
if(indexPath.row == 0)
{
if(self.message.image)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"HILargeMessageImageCell"];
[(HILargeMessageImageCell *)cell initWithMessage:self.message];
}else{
cell = [tableView dequeueReusableCellWithIdentifier:@"HILargeMessageCell"];
[(HILargeMessageCell *)cell initWithMessage:self.message];
}
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:@"HIChildMessageCell"];
[(HIChildMessageCell *)cell initWithMessage:[self.comments objectAtIndex:indexPath.row-1]];
}
cell.bounds = CGRectMake(0.0f,0.0f, CGRectGetWidth(self.tableView.bounds), CGRectGetHeight(cell.bounds));
[cell setNeedsLayout];
[cell layoutIfNeeded];
CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
NSLog(@"HEight is: %f",height);
return height + 1.0f; // Add 1.0 for the cell spacer
}
인터페이스 빌더 내에서 제약 조건을 수행했습니다. –
셀을 삭제하고 다시 처리하면 모든 것이 다시 작동합니다. 무슨 일이 일어 났는지 누가 알 겠어! –
IB에서 엉망진창이 생기고 셀 높이가 실제로 0 이었음을 기꺼이 확신합니다. – ansible