我无法使这些滑块对齐,我不确定为什么。
这是我的故事板...尾随的约束显然被忽略了。我在做什么错了?
编辑:哑光
和控制拖动它们中的两个,应该足够了:trailing: 14
和center Y
(现在在超级视图中,rh被标记是错误的)。没有任何绘制的约束上的“在运行时删除”。
这些标志是可见的,但是没有指示它们的含义(大小检查器无助地只说“具有不明确的约束”)。
根据此处的输入和快速的不一致,下面是应用了更改的视图示例:
<tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" restorationIdentifier="RootAppCell" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="RootAppCell" id="PDl-Cx-SrR" customClass="RootAppCell" customModule="Assignment_5">
<rect key="frame" x="0.0" y="28" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="PDl-Cx-SrR" id="EHS-uv-XgI" customClass="RootAppCell" customModule="Assignment_5">
<rect key="frame" x="0.0" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uDJ-B5-x3A">
<rect key="frame" x="277" y="6" width="51" height="31"/>
</switch>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="App Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fWL-xO-z8g">
<rect key="frame" x="18" y="11" width="81" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="fWL-xO-z8g" firstAttribute="centerY" secondItem="EHS-uv-XgI" secondAttribute="centerY" id="G84-Ys-Q8G"/>
<constraint firstItem="fWL-xO-z8g" firstAttribute="leading" secondItem="EHS-uv-XgI" secondAttribute="leadingMargin" constant="3" id="JrD-j0-SxV"/>
<constraint firstItem="uDJ-B5-x3A" firstAttribute="centerY" secondItem="EHS-uv-XgI" secondAttribute="centerY" id="Q5Q-sy-Qh7"/>
<constraint firstAttribute="trailingMargin" secondItem="uDJ-B5-x3A" secondAttribute="trailing" constant="2" id="bMt-16-diy"/>
<constraint firstItem="uDJ-B5-x3A" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="fWL-xO-z8g" secondAttribute="trailing" id="he7-G6-aBc"/>
</constraints>
</tableViewCellContentView>
答案 0 :(得分:1)
如果您不清楚哪些约束冲突,请在加载屏幕时查看控制台输出,您应该能够看到与此类似的内容
(
"<NSLayoutConstraint:0x6199cd0 UIButton:0x7fbbf90.width == 0 (active)>",
"<NSLayoutConstraint:0x6998ec0 H:|-(15)-[UILabel:0x6ce60] (active, names: '|':UIButton:0x7fbbf90 )>",
"<NSLayoutConstraint:0x6199000 H:[UILabel:0x6ce60]-(15)-| (active, names: '|':UIButton:0x7fbbf90 )>"
)
为进一步帮助您,您可以使用此网页粘贴该部分,它至少会告诉您代码中哪些约束冲突。.
https://www.wtfautolayout.com/
表视图单元格可能很棘手,因为它们将基于例如您设置为单元格的行高等而受到其他约束。
希望这有助于调试
答案 1 :(得分:0)