Ограничение автопоставки исчезает во время выполнения - PullRequest
0 голосов
/ 18 февраля 2020

У меня есть простая ячейка табличного представления, содержащая две метки, ограничения позиционирования которых исчезают во время выполнения (ширина и соотношение сторон остаются). Нет предупреждений, нет ошибок в представлении раскадровки, нет журнала консоли, и я не использую классы размеров.

Представления неуместны (они придерживаются верхнего левого угла), и когда я запускаю представление отладки В иерархии есть восклицательный знак на фиолетовом фоне, указывающий на неоднозначную позицию. После проверки выясняется, что ограничений позиции больше нет.

Я попытался удалить и добавить их снова, я сравнил почти каждый инспектор IB в иерархии представления с работающей реализацией и не смог выяснить разница. Я проверил представления с помощью lldb, и _autolayoutTrace не показывает ограничений.

Я знаю, что могу удалить контроллер в Интерфейсном Разработчике и перестроить его, но я был бы признателен за понимание отладки такого рода проблемы.

Вот часть раскадровки, описывающая контроллер табличного представления и ячейку прототипа:

<tableViewController id="RTg-bl-d8Z" customClass="ChekListViewController" customModule="Todo_app" customModuleProvider="target" sceneMemberID="viewController">
    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="5dF-Vx-S1N">
        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
        <prototypes>
            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="detailDisclosureButton" indentationWidth="10" reuseIdentifier="checkListItem" id="a6e-eR-CO4" customClass="CheckListItemCell" customModule="Todo_app" customModuleProvider="target">
                <rect key="frame" x="0.0" y="28" width="414" height="57.5"/>
                <autoresizingMask key="autoresizingMask"/>
                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="a6e-eR-CO4" id="EUI-T4-UFi" customClass="CheckListItemCell" customModule="Todo_app" customModuleProvider="target">
                    <rect key="frame" x="0.0" y="0.0" width="351" height="57.5"/>
                    <autoresizingMask key="autoresizingMask"/>
                    <subviews>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="✔️" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KM3-zM-YXK">
                            <rect key="frame" x="28" y="11" width="25.5" height="35.5"/>
                            <constraints>
                                <constraint firstAttribute="width" constant="25" id="uyC-B0-CMt"/>
                                <constraint firstAttribute="width" secondItem="KM3-zM-YXK" secondAttribute="height" multiplier="25:35" id="yPH-cC-BhV"/>
                            </constraints>
                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
                            <nil key="textColor"/>
                            <nil key="highlightedColor"/>
                        </label>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I1F-jX-unK">
                            <rect key="frame" x="61.5" y="18.5" width="281.5" height="21"/>
                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
                            <nil key="textColor"/>
                            <nil key="highlightedColor"/>
                        </label>
                    </subviews>
                    <constraints>
                        <constraint firstAttribute="trailingMargin" secondItem="I1F-jX-unK" secondAttribute="trailing" id="2DJ-vu-eZH"/>
                        <constraint firstItem="I1F-jX-unK" firstAttribute="centerY" secondItem="KM3-zM-YXK" secondAttribute="centerY" id="5sk-xI-Lws"/>
                        <constraint firstItem="KM3-zM-YXK" firstAttribute="leading" secondItem="EUI-T4-UFi" secondAttribute="leadingMargin" constant="8" id="T2a-1U-YX9"/>
                        <constraint firstItem="I1F-jX-unK" firstAttribute="leading" secondItem="KM3-zM-YXK" secondAttribute="trailing" constant="8" id="a2G-6H-iVm"/>
                        <constraint firstItem="KM3-zM-YXK" firstAttribute="bottom" secondItem="EUI-T4-UFi" secondAttribute="bottomMargin" id="c6K-zY-2tu"/>
                        <constraint firstItem="KM3-zM-YXK" firstAttribute="top" secondItem="EUI-T4-UFi" secondAttribute="topMargin" id="z4V-Rz-c6k"/>
                    </constraints>
                </tableViewCellContentView>
                <connections>
                    <outlet property="checkMark" destination="KM3-zM-YXK" id="qY4-JT-7iv"/>
                    <outlet property="textItem" destination="I1F-jX-unK" id="eID-MO-fVV"/>
                    <segue destination="Kuh-LZ-DVA" kind="presentation" identifier="editItem" trigger="accessoryAction" id="DeL-Ql-cQq"/>
                </connections>
            </tableViewCell>
        </prototypes>
        <sections/>
        <connections>
            <outlet property="dataSource" destination="RTg-bl-d8Z" id="34r-cH-2bg"/>
            <outlet property="delegate" destination="RTg-bl-d8Z" id="CsE-gc-hUN"/>
        </connections>
    </tableView>
    <navigationItem key="navigationItem" title="Name of the list" id="05Z-xs-cMG">
        <barButtonItem key="rightBarButtonItem" systemItem="add" id="oSl-fh-Gh3">
            <connections>
                <segue destination="Kuh-LZ-DVA" kind="presentation" identifier="addItem" id="6cn-yq-cSG"/>
            </connections>
        </barButtonItem>
    </navigationItem>
</tableViewController>

1 Ответ

1 голос
/ 19 февраля 2020

ОК, это было неочевидно ... до тех пор, пока это не было:)

Каким-то образом - либо щелчком "упс", либо какой-то причудой Xcode / IB - Content View вашей ячейки получил свой класс, установленный на CheckListItemCell:

enter image description here

Выберите ячейки Content View, go на панели Identity Inspector и измените Custom Class на значение по умолчанию UIView:

enter image description here

Лучший результат:

enter image description here

...