UITableViewCell의 크기를 올바르게 지정하여 UILabel 및 UITextView에 맞춰 레이블 내의 모든 텍스트와 textView를 볼 수있게하려고합니다.UITextView를 사용하여 UITableViewCell의 AutoLayout
이제 textView에 적절한 크기를 얻는 데 문제가 있습니다. 지금, 나는 내 펜촉 아래 레이블을 통해 마지막으로 셀의 아래로 셀의있는 contentView의 상단을 고정 제약이 있는지 확인했습니다
if (_prototypeCell == nil) {
_prototypeCell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([DDDataDetectingDetailCell class]) owner:nil options:0] lastObject];
}
[_prototypeCell setFrame:CGRectMake(0, 0, CGRectGetWidth(self.tableView.frame), 1)];
[_prototypeCell configureForItem:self.items[indexPath.row]];
[_prototypeCell setNeedsLayout];
[_prototypeCell layoutIfNeeded];
CGSize size = [_prototypeCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height + 1;
: 여기 내 레이아웃 코드입니다. 또한 셀에는 수평 치수를 따라 연결하는 제약이 있습니다.
(lldb) po _prototypeCell
<DDDataDetectingDetailCell: 0x79bd4700; baseClass = UITableViewCell; frame = (0 0; 320 1); autoresize = RM+BM; layer = <CALayer: 0x79bbba90>>
(lldb) po _prototypeCell.detailTextView
<UITextView: 0x7b9ffc00; frame = (15 1; 290 0); text = 'No need to pay -- Just le...'; clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x79bce590>; layer = <CALayer: 0x79bd6910>; contentOffset: {0, 0}; contentSize: {290, 0}>
따라서 텍스트 뷰가 나타납니다 : 나는 텍스트 뷰 셀을 인쇄하는 경우, 나는이 얻을 수 있기 때문에
(width=486.5, height=61.5)
이 홀수 :이 크기를 인쇄 할 경우, 나는 다음과 같은 수 올바른 너비가 될 수는 있지만 어떤 이유로 인해 구속 조건에 따라 높이가 계산되지 않습니다. 여기
내 layoutSubviews 방법입니다 :
- (void)layoutSubviews {
[super layoutSubviews];
self.mainLabel.preferredMaxLayoutWidth = self.mainLabel.frame.size.width;
[super layoutSubviews];
}
그리고 여기 내 제약의 그림입니다 :
가 왜 -systemLayoutFittingSize:
에서이 펑키 너비는 무엇입니까?
UPDATE
내가 잘못 (width=456.5, height=32.5)
셀 클래스 내부의 UITextView에'self.textView.scrollEnabled = NO; '를 설정 했습니까? – Zhang
예, 불행히도,이 작업을하지 못했습니다. –
인터페이스 빌더를 사용하여 구현 했습니까? – Zhang