2014-04-16 2 views
0

내부에 사용자 정의 셀이있는 tableview가 있습니다. 여기에 텍스트 뷰가 있습니다. 이 셀에서는 텍스트의 크기에 따라 높이가 결정됩니다. 내 셀 나는이 방법으로 모든 공간 셀에 대한 텍스트 뷰를 확장하는 두 가지 제약 조건을 사용할 수 있도록iOS : 사용자 정의 테이블 뷰 셀의 제약

나는, 자동 레이아웃에서 작동

enter image description here

나는 그것이 잘 작동하고 내 텍스트 뷰가 자신을 확장하는 것이 말할 수

모든 셀 공간.

보기 컨트롤러에는 텍스트 (문자열)가 비어 있는지 확인하는 컨트롤이 있습니다. 비어있을 때 셀 높이에 0을 반환합니다.

하지만이 경우에는 0을 반환하고 text_view는 비어 있는데 충돌이 발생하지만 해결 방법을 모르겠습니다.

이 왜 당신이 아무 내용이없는 경우 행을 포함하는 메시지

Unable to simultaneously satisfy constraints. 

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x1704864a0 V:|-(25)-[UITextView:0x15454d960] (Names: '|':UITableViewCellContentView:0x178179680)>", 
    "<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-| (Names: '|':UITableViewCellContentView:0x178179680)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x17889a220 h=--& v=--& V:[UITableViewCellContentView:0x178179680(0)]>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1704864f0 V:[UITextView:0x15454d960]-(23)-| (Names: '|':UITableViewCellContentView:0x178179680)> 

Break on objc_exception_throw to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 
+1

은? – Wain

+1

커스텀 셀에'[self.contentView setTranslatesAutoresizingMaskIntoConstraints : NO];를 설정해보십시오. – Akhilrajtr

+0

뷰의 알파를 0으로 설정하는 것이 뷰를 숨기는 더 좋은 방법입니다. – BoranA

답변

1

에 의한 세포있는 contentView의 NO으로 설정 TranslatesAutoresizingMaskIntoConstraints,

[self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO]; 
관련 문제