UICollectionViewCell 내에서 autolayout을 사용하고 있습니다. 슈퍼 간단한 레이아웃 : 그냥 UILabel. 나는 UILabel이 전폭에서 20 px 인세트를 뺀 것을 세로 및 가로로 셀 중앙에두기를 원합니다. 나는 그런 제약을 설정했다. ios 8 장치 나 시뮬레이터에서 실행하면 완벽하게 작동합니다. 그러나, 일부 iOS 7 디바이스에서 실행할 때 제약 조건이 적용되지 않습니다. 애플 문서를 살펴 보았지만 자동 레이아웃과 관련된 변경 사항은 없습니다. 답변보다 해결의AutoLayout은 ios 8에서는 작동하지만 ios 7에서는 작동하지 않습니까?
<constraints>
<constraint firstItem="OIc-cg-9hO" firstAttribute="leading" secondItem="Ga6-nx-lOn" secondAttribute="leading" constant="20" id="A7U-sd-fcL"/>
<constraint firstAttribute="centerY" secondItem="OIc-cg-9hO" secondAttribute="centerY" id="G9e-9W-aDS"/>
<constraint firstAttribute="centerX" secondItem="OIc-cg-9hO" secondAttribute="centerX" id="TrB-hI-7Kw"/>
<constraint firstAttribute="trailing" secondItem="OIc-cg-9hO" secondAttribute="trailing" constant="20" id="yjH-nf-D9U"/>
</constraints>
더 : 나는 그것이 훨씬 의미 의심하지만 여기
는 XML 소스 코드입니다하지만 다음과 같이 나는 코드에서 제약 조건을 추가 :[self addConstraint:[NSLayoutConstraint constraintWithItem:self.cellName
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeWidth
multiplier:1.0
constant:-20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem:self.cellName
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem:self.cellName
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeCenterY
multiplier:1.0
constant:0.0]];
위해 그것이 작동하려면 코드 된 제약 조건과 IB 제약 조건이 모두 필요했습니다. Dunno 왜!
당신이 아이폰 OS 7 어떤 결과를 얻을 수 있습니까? iOS 7에서는 작동하지 않아야하는 제약 사항이 없습니다. – rdelmar
UILabel은 xib의 정확한 높이와 너비를 가지고 있습니다. – user3534641
동일한 설치 및 문제가 있습니다. 아직 어떤 해결책이 있습니까? – Ravi