【发布时间】:2015-11-17 01:33:43
【问题描述】:
我有一个UITableViewController,其中包含一组带有一些动态内容的静态 UITableViewCell,但升级到 XCode 7 后,单元格不再调整大小,并且内容与下面的单元格重叠。我注意到故事板中添加了以下“rect”标签。
<rect key="frame" x="8" y="8" width="584" height="584"/>
单元格内的内容是UIImageView,具有 1:1 的比例约束,因此它始终贴在两侧并调整高度。
UITableViewCell 的约束。
<tableViewCell userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="TeM-3R-AKy">
<rect key="frame" x="0.0" y="124" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TeM-3R-AKy" id="Ul9-Ad-TSI">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="yolo" translatesAutoresizingMaskIntoConstraints="NO" id="Dno-dR-6h7">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<animations/>
<constraints>
<constraint firstAttribute="width" secondItem="Dno-dR-6h7" secondAttribute="height" multiplier="1:1" id="4gQ-ye-O6k"/>
<constraint firstAttribute="height" priority="999" constant="60" id="cBT-jH-WiC"/>
</constraints>
</imageView>
</subviews>
<animations/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Dno-dR-6h7" secondAttribute="trailing" id="0K4-U7-ueq"/>
<constraint firstItem="Dno-dR-6h7" firstAttribute="leading" secondItem="Ul9-Ad-TSI" secondAttribute="leading" id="2ER-Tt-FFc"/>
<constraint firstAttribute="bottom" secondItem="Dno-dR-6h7" secondAttribute="bottom" priority="999" id="jfg-iH-H9u"/>
<constraint firstItem="Dno-dR-6h7" firstAttribute="top" secondItem="Ul9-Ad-TSI" secondAttribute="top" id="mcU-xf-gfx"/>
</constraints>
</tableViewCellContentView>
<animations/>
</tableViewCell>
可能重复: iOS8 self-sizing static TableView cells with Interface Builder
【问题讨论】:
-
重置约束一次,如果您仍然遇到问题,请尝试。
-
@PK20 你的意思是重置为建议?您指的是哪些约束?我不认为 xcode 知道我想做什么.. 但是我尝试在将 UIImageView 安装到单元格中后重置它的约束而没有结果。
-
未重置为建议值。当您升级到 Xcode7 时,约束可能没有正确复制。最好清除所有约束并重新设置。我知道这很痛苦,但这是唯一的方法。
-
啊。试过了。结果相同。也许 xcode 7 发生了一些变化,或者我做错了什么。
-
你能透露你为单元格设置的约束吗?
标签: ios xcode uitableview xcode7 ios-autolayout