제약 조건이 높이 0을 모호하게 제안하는 경우 감지
tableview 셀이 포함 된 앱을 실행할 때 Xcode 6.1 베타 2로 업데이트 한 후 디버그 도우미가 다음과 같이 말합니다.
Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
이전에이 프로젝트에서 Xcode 5를 사용했을 때 몇 가지 오류가 발생했지만 업그레이드 한 이후로 사라졌습니다. 지금은 다른 오류나 경고가 없습니다. 이미 모든 tableview 셀의 크기를 조정하고 표준 높이를 사용해 보았지만 여전히 동일한 경고가 표시됩니다.
Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
나는 또한 이것에 대한 모든 유사한 주제를 읽었지만 그들의 솔루션은 도움이되지 않습니다. 시뮬레이터로 앱을 테스트하면 tableView 셀에 있어야하는 그림이없는 경우를 제외하고 앱이 정상적으로 실행됩니다.
지금까지 세 가지가이 경고를 침묵 시켰습니다. 가장 편리한 것을 선택할 수 있습니다. 그래도 예쁜 것은 없습니다.
viewDidLoad에서 기본 셀의 높이를 설정하려면
self.tableView.rowHeight = 44;
스토리 보드로 이동하여 tableview의 행 높이를 44가 아닌 다른 것으로 변경하십시오.
tableview의 대리자 메서드 heightForRowAtIndexPath를 구현하려면
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44; }
기묘한.
iOS8의 Tableviews : Automatic Row Heights의 환상적인 새로운 기능의 부작용이 있습니다.
iOS 7에서는 고정 된 크기의 행 (로 설정 tableView.rowHeight
)이 있거나 셀의 높이를 계산하는 코드를 작성하여 tableView:heightForRowAtIndexPath
. 셀에 많은 뷰가 있고 다른 글꼴 크기에서 고려할 높이가 다른 경우 셀 높이 계산을위한 코드를 작성하는 것은 매우 복잡 할 수 있습니다. Dynamic Type을 추가하고 프로세스는 엉덩이에 고통이었습니다.
iOS 8에서도 위의 작업을 수행 할 수 있지만 이제 자동 레이아웃을 사용하여 셀의 콘텐츠를 구성한 경우 iOS에서 행의 높이를 결정할 수 있습니다. 동적 글꼴 크기가 변경되거나 사용자가 접근성 설정을 사용하여 텍스트 크기를 수정하면 UI가 새로운 크기에 적응할 수 있기 때문에 이는 개발자에게 큰 이점입니다. 또한 여러 행의 텍스트를 포함 할 수있는 UILabel이있는 경우 이제 셀이 필요할 때이를 수용하도록 셀을 확장 할 수 있고 그렇지 않을 때 축소 할 수 있으므로 불필요한 공백이 없습니다.
표시되는 경고 메시지는 자동 레이아웃에 대한 셀의 제약 조건이 충분하지 않아 테이블 뷰에 셀 높이를 알려주는 것입니다.
다른 포스터에서 이미 언급 한 기술과 함께이 메시지를 제거하는 동적 셀 높이를 사용하려면 셀에 UI 항목을 셀 의 상단 과 하단 에 바인딩하기에 충분한 제약 조건이 있는지 확인해야합니다 . 이전에 자동 레이아웃을 사용한 적이 있다면 Top + Leading 제약 조건을 설정하는 데 익숙 할 것입니다.하지만 동적 행 높이에도 아래쪽 제약 조건이 필요합니다.
레이아웃 단계는 다음과 같이 작동하며, 화면에 셀이 적시에 표시되기 직전에 발생합니다.
고유 크기가있는 콘텐츠의 크기가 계산됩니다. 여기에는 UILabels 및 UIImageViews가 포함되며, 여기에서 크기는 각각 포함 된 텍스트 또는 UIImage를 기반으로합니다. 이 두보기는 모두 너비를 알려진 것으로 간주합니다 (후행 / 선행 가장자리에 대한 제약 조건을 설정했거나 명시 적 너비를 설정했거나 결국 가로 제한을 사용하여 좌우로 너비를 표시하기 때문). 레이블에 텍스트 단락이 있다고 가정 해 보겠습니다 ( "줄 수"가 0으로 설정되어 자동 줄 바꿈 됨). 310 포인트 만 가능하므로 현재 글꼴 크기에서 120pt 높이로 결정됩니다.
UI는 위치 제약에 따라 배치됩니다. 셀의 아래쪽 여백에 연결되는 레이블 아래쪽에 제약 조건이 있습니다. 레이블이 120 포인트 높이로 성장하고 제약 조건에 의해 셀의 맨 아래에 바인딩되었으므로 "bottom of"라는 제약 조건을 충족하려면 셀을 "아래로"(셀 높이 증가) 밀어야합니다. 레이블은 항상 셀 하단에서 표준 거리입니다.
보고 한 오류 메시지는 아래쪽 제약 조건이 누락 된 경우 발생합니다.이 경우 셀 맨 아래를 셀 맨 위에서 "밀어 낼"것이 없습니다. 이는보고 된 모호성입니다. 맨 아래를 밀지 않습니다. 상단, 셀이 무너집니다. 그러나 자동 레이아웃도이를 감지하고 표준 행 높이를 사용하는 방식으로 돌아갑니다.
가치가 있고 대부분 반올림 된 답변을 얻으려면 iOS 8의 자동 레이아웃 기반 동적 행 높이를 구현하는 경우 tableView:estimatedHeightForRowAtIndexPath:
. 이 추정 방법은 셀에 대한 대략적인 값을 사용할 수 있으며 테이블보기가 처음로드 될 때 호출됩니다. UIKit이 스크롤바와 같은 것을 그리는 데 도움이되는데, 이는 tableview가 스크롤 할 수있는 콘텐츠의 양을 알지 못하면 그릴 수 없지만 스크롤바 일 뿐이므로 완전히 정확한 크기는 필요하지 않습니다. 이렇게하면 셀이 필요한 순간까지 실제 행 높이의 계산을 연기 할 수 있습니다. 이렇게하면 계산 집약적이지 않고 UITableView가 더 빨리 표시됩니다.
프로그래밍 방식없이이 문제를 해결하려면 스토리 보드의 크기 검사기에서 테이블보기의 행 높이를 조정하십시오.
I had this problem after creating a custom UITableViewCell
and adding my subviews to the cell instead of its contentView
.
This is an autolayout issue. Make sure that your subviews have all the constraints. For me, the bottom constraint was missing for the Title Label in the cell. When I added that, the warning went away and everything showed up perfectly.
I got this warning today. Here is what made it disappear for me(in interface builder)
1.Set the row height field for the table view to something other than 44 2 Set the row height field for the tableView cell to something other than 44
I did not have to make any changes in code
If u are using static cell or dynamic cell ,simply add some row height to table view in inspector table and uncheck the automatic to the right side of row height ,that's it u will stop getting this warning .
Just enable Self-Sizing Table View Cells
tableView.estimatedRowHeight = 85.0
tableView.rowHeight = UITableViewAutomaticDimension
& make sure you added constraints on all sides of UITableViewCell
as-
In my case, I was building the cell programmatically and kept getting this error.
I was adding the subviews and constraints in the UITableViewCell
's init
method like this:
addSubview(rankingLabel)
addConstraints(cellConstraints)
I solved the issue by adding them to the cell's contentView
instead:
contentView.addSubview(rankingLabel)
contentView.addConstraints(cellConstraints)
I too experienced this warning with moving to Xcode 6 GM. I was only getting the warning when I rotated the device back to its original position.
I am using custom UITableViewCells. The storyboard table view is set to my custom size (100.0 in my case). While the table cells render properly as they have in previous releases, I did not like warning message.
In addition to the above ideas, I added this
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100.0;
}
Screen renders... responds to rotation and no more warning messages.
In xcode 6.0.1 I had removed this warnings specifying the row height using:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44.0;
}
Set the estimated row height to zero and the warning disappears:
If you have created a Custom tableViewCell for tableView, make sure you have given both bottom and top constraints to you cells, you could also get this message if your subviews inside custom cells are aligned in center Y which wouldnt pop any error message but would mess up with identifying height of row for tableview in turn like in Image I have attached , here we have both top and bottom constraints
When you create a Custom Cell for tableView you must specific row height or top and bottom constraints for you custom cell's subviews inside cell (e.g. label in custom cell like in below image)
But if this doesn't work you can try setting row height for your cell instead of being automatic like in this image
But be sure if you turn that automatic tick off you have to adjust your row size for changes programmatically which could have been done automatically
In the storyboard set the cell
Row height
field with the same value as Row height
in tableView
(both with the same value worked for me).
If you add heightForRowAtIndexPath
function to your code it may induce a performance issue because it will be called for each cell so be careful.
You may also see this message if your only constraints are set to align all items vertically and you don't have/want a height specified for the cell. If you set a top/bottom constraint on the item the warning will disappear.
사용자 정의 tableViewCell의 레이블 및보기가 Content View가 아닌 customCell로 제한되었을 때이 문제가 발생했습니다. 제약 조건을 지우고 콘텐츠보기 셀에 연결하면 문제가 해결되었습니다.
동일한 오류 메시지가 나타났습니다. 모든 콘센트가 테이블 뷰 및 테이블 뷰 제약 조건과 같이 유효한지 확인하십시오.
이 줄로 인해이 오류가 표시되었습니다.
self.layer.backgroundColor = UIColor (white : 1, alpha : 0.2) as! CGColor
오류를 수정하기 위해 다음과 같이 줄을 변경합니다.
self.layer.backgroundColor = UIColor (흰색 : 1, 알파 : 0.2) .cgColor
'Programming' 카테고리의 다른 글
Laravel 5-HTTPS로 리디렉션 (0) | 2020.08.10 |
---|---|
NuGet 자동 패키지 복원이 MSBuild에서 작동하지 않음 (0) | 2020.08.10 |
Netbeans 성능을 향상시키는 방법은 무엇입니까? (0) | 2020.08.09 |
PhoneGap Eclipse 문제-eglCodecCommon glUtilsParamSize : 알 수없는 매개 변수 오류 (0) | 2020.08.09 |
웹 사이트를위한 단순 / 최소한 browserconfig.xml은 무엇입니까? (0) | 2020.08.09 |