UITableViewCell
(사용자 정의 backgroundColor가 변경됨), 사용자 정의를 얻을 수 있지만 그 제약 조건은 모두 손실됩니다.스토리 보드의 사용자 정의 tableViewCell이 iOS8.1에서 자동 레이아웃 제약을 잃었습니다
ps. Xcode 6.1.1을 사용하고 있습니다.
올바른 높이 값을 가져오고 싶지만 구속 조건이 모두 손실됩니다.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
static HomeMainNewsCell *mainCell = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
mainCell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeMainNewsCell"];
});
[mainCell.titleLabel setText:@"dsfjsdhfjsasdfsdfdsfsdfsdfsdfk"];
[mainCell layoutIfNeeded];
CGFloat height = [mainCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return height;
}
그것은 로그 여기
po [mainCell.contentView constraints]
<__NSArrayM 0x7fe05b745c10>(
)
입니다 것은 스토리 보드 스크린 샷을하다
나는 heightForRowAtIndexPath이 methed 삭제 후에는 iOS8의에서 완벽하게 표시합니다 추가 정보. 1.
그러나 iOS7.1에서는 모든 셀의 높이 값이 44이므로 표시됩니다. 그리고 제약 조건은 모두 되돌아갑니다.
po [mainCell.contentView constraints]
<__NSArrayM 0x78e50f20>(
<NSLayoutConstraint:0x78e52a10 UILabel:0x78e524d0.trailing == UITableViewCellContentView:0x78e52230.trailing - 8>,
<NSLayoutConstraint:0x78e52a40 V:[UILabel:0x78e524d0]-(17)-| (Names: '|':UITableViewCellContentView:0x78e52230)>,
<NSLayoutConstraint:0x78e52a70 H:|-(8)-[UILabel:0x78e524d0] (Names: '|':UITableViewCellContentView:0x78e52230)>,
<NSLayoutConstraint:0x78e52aa0 V:[UILabel:0x78e52380]-(9)-[UILabel:0x78e524d0]>,
<NSLayoutConstraint:0x78e52ad0 UILabel:0x78e52380.trailing == UITableViewCellContentView:0x78e52230.trailing - 8>,
<NSLayoutConstraint:0x78e52b00 V:[UIImageView:0x78e522d0]-(9)-[UILabel:0x78e52380]>,
<NSLayoutConstraint:0x78e52b30 H:|-(8)-[UILabel:0x78e52380] (Names: '|':UITableViewCellContentView:0x78e52230)>,
<NSLayoutConstraint:0x78e52b60 H:|-(0)-[UIImageView:0x78e522d0] (Names: '|':UITableViewCellContentView:0x78e52230)>,
<NSLayoutConstraint:0x78e52b90 H:[UIImageView:0x78e522d0]-(0)-| (Names: '|':UITableViewCellContentView:0x78e52230)>,
<NSLayoutConstraint:0x78e52bc0 V:|-(0)-[UIImageView:0x78e522d0] (Names: '|':UITableViewCellContentView:0x78e52230)>
)
제한 사항은 어떻게 추가됩니까? cell.constrains 로그인을 시도 했습니까? –
@Clement 나는 Storyboard에서 그들을 추가했다. 그리고 예, 나는 그것을 기록했고 높이 값이 정확하지 않은 이유임을 발견했다. –
크기 클래스를 사용하고 있습니까? –