swift 4:我的场景中的文本字段都不可编辑

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 4:我的场景中的文本字段都不可编辑相关的知识,希望对你有一定的参考价值。

我的故事板中有一个场景,它的所有字段在应用程序运行时都不可编辑。

注意。我已经检查了所有文本字段及其所有父userInteractionEnabled都是true并且由于这个问题(My TextField is not editable)但它没有帮助。我有这样的其他场景,不使用任何代表或这样的东西工作,他们的文本字段仍然是可编辑的。

我确实在其相关的视图控制器中注释了所有内容,但它没有改变这种情况。我在这里提供了它的XML代码供您参考,也许你可以找到导致这种情况的任何东西。

我对我的场景所做的更改是:在StackView内嵌套视图中的所有项目以及它的一些约束+从Swift 3迁移到Swift 4。

<viewController storyboardIdentifier="CreateNewAddressViewController" id="meF-fr-sNf" customClass="CreateNewAddressViewController" customModule="nopStation" customModuleProvider="target" sceneMemberID="viewController">
    <view key="view" contentMode="scaleToFill" id="AwK-Dk-u5T">
        <rect key="frame" x="0.0" y="0.0" width="375" height="800"/>
        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
        <subviews>
            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FhN-qH-KZv">
                <rect key="frame" x="10" y="84" width="355" height="646"/>
                <subviews>
                    <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="goD-MV-xj2">
                        <rect key="frame" x="0.0" y="0.0" width="355" height="590"/>
                        <subviews>
                            <stackView opaque="NO" contentMode="scaleToFill" fixedFrame="YES" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="o9G-FL-lqF">
                                <rect key="frame" x="10" y="0.0" width="335" height="290"/>
                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                <subviews>
                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WMA-Km-72c">
                                        <rect key="frame" x="0.0" y="0.0" width="335" height="40"/>
                                        <subviews>
                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="First Name" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fKn-8z-Pzc">
                                                <rect key="frame" x="0.0" y="0.0" width="316.5" height="40"/>
                                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                <textInputTraits key="textInputTraits"/>
                                            </textField>
                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="*" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fUe-Bq-W8T">
                                                <rect key="frame" x="326.5" y="9.5" width="8.5" height="21.5"/>
                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
                                                <color key="textColor" name="RequiredFieldColor"/>
                                                <nil key="highlightedColor"/>
                                            </label>
                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dMl-Cd-fC6">
                                                <rect key="frame" x="0.0" y="38" width="335" height="2"/>
                                                <color key="backgroundColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                <constraints>
                                                    <constraint firstAttribute="height" constant="2" id="Yrr-ai-qmM"/>
                                                </constraints>
                                            </view>
                                        </subviews>
                                        <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                        <constraints>
                                            <constraint firstItem="dMl-Cd-fC6" firstAttribute="leading" secondItem="WMA-Km-72c" secondAttribute="leading" id="4z7-jV-IUk"/>
                                            <constraint firstAttribute="bottom" secondItem="dMl-Cd-fC6" secondAttribute="bottom" id="F8F-RI-rg4"/>
                                            <constraint firstItem="fUe-Bq-W8T" firstAttribute="centerY" secondItem="WMA-Km-72c" secondAttribute="centerY" id="I89-Go-X44"/>
                                            <constraint firstAttribute="bottom" secondItem="fKn-8z-Pzc" secondAttribute="bottom" id="JTN-Ml-5Eo"/>
                                            <constraint firstItem="fUe-Bq-W8T" firstAttribute="leading" secondItem="fKn-8z-Pzc" secondAttribute="trailing" constant="10" id="RcN-3E-CP8"/>
                                            <constraint firstAttribute="trailing" secondItem="dMl-Cd-fC6" secondAttribute="trailing" id="X8s-r3-rol"/>
                                            <constraint firstItem="fKn-8z-Pzc" firstAttribute="top" secondItem="WMA-Km-72c" secondAttribute="top" id="bek-aj-mKk"/>
                                            <constraint firstItem="fKn-8z-Pzc" firstAttribute="leading" secondItem="WMA-Km-72c" secondAttribute="leading" id="ghL-fb-IFL"/>
                                            <constraint firstAttribute="trailing" secondItem="fUe-Bq-W8T" secondAttribute="trailing" id="tmI-VS-dyA"/>
                                            <constraint firstAttribute="height" constant="40" id="xLm-i2-YEp"/>
                                        </constraints>
                                    </view>
                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="P0X-pA-gjs">
                                        <rect key="frame" x="0.0" y="50" width="335" height="40"/>
                                        <subviews>
                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Last Name" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="DfQ-XX-xII">
                                                <rect key="frame" x="0.0" y="0.0" width="316.5" height="40"/>
                                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                <textInputTraits key="textInputTraits"/>
                                            </textField>
                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="*" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7TX-E6-XLu">
                                                <rect key="frame" x="326.5" y="9.5" width="8.5" height="21.5"/>
                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
                                                <color key="textColor" name="RequiredFieldColor"/>
                                                <nil key="highlightedColor"/>
                                            </label>
                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5hQ-6V-Wq0">
                                                <rect key="frame" x="0.0" y="38" width="335" height="2"/>
                                                <color key="backgroundColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                <constraints>
                                                    <constraint firstAttribute="height" constant="2" id="FNO-9t-n52"/>
                                                </constraints>
                                            </view>
                                        </subviews>
                                        <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                        <constraints>
                                            <constraint firstItem="DfQ-XX-xII" firstAttribute="top" secondItem="P0X-pA-gjs" secondAttribute="top" id="0g2-tp-rW4"/>
                                            <constraint firstAttribute="trailing" secondItem="5hQ-6V-Wq0" secondAttribute="trailing" id="8eK-Vx-f2y"/>
                                            <constraint firstAttribute="bottom" secondItem="5hQ-6V-Wq0" secondAttribute="bottom" id="Fiu-Kw-SJQ"/>
                                            <constraint firstAttribute="bottom" secondItem="DfQ-XX-xII" secondAttribute="bottom" id="LqW-0G-dQv"/>
                                            <constraint firstItem="5hQ-6V-Wq0" firstAttribute="leading" secondItem="P0X-pA-gjs" secondAttribute="leading" id="RAi-YU-lOk"/>
                                            <constraint firstItem="DfQ-XX-xII" firstAttribute="leading" secondItem="P0X-pA-gjs" secondAttribute="leading" id="hQA-Cy-Icv"/>
                                            <constraint firstAttribute="height" constant="40" id="jpn-Ph-BBz"/>
                                            <constraint firstItem="7TX-E6-XLu" firstAttribute="centerY" secondItem="P0X-pA-gjs" secondAttribute="centerY" id="kXU-Bp-hcH"/>
                                            <constraint firstAttribute="trailing" secondItem="7TX-E6-XLu" secondAttribute="trailing" id="wc4-6s-KgF"/>
                                            <constraint firstItem="7TX-E6-XLu" firstAttribute="leading" secondItem="DfQ-XX-xII" secondAttribute="trailing" constant="10" id="zHs-Pr-2vS"/>
                                        </constraints>
                                    </view>
                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Nnr-ax-dhk">
                                        <rect key="frame" x="0.0" y="100" width="335" height="40"/>
                                        <subviews>
                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Email" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="BhZ-fY-4k7">
                                                <rect key="frame" x="0.0" y="0.0" width="316.5" height="40"/>
                                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                <textInputTraits key="textInputTraits"/>
                                            </textField>
                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="*" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="j0N-ZY-V0Y">
                                                <rect key="frame" x="326.5" y="9.5" width="8.5" height="21.5"/>
                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
                                                <color key="textColor" name="RequiredFieldColor"/>
                                                <nil key="highlightedColor"/>
                                            </label>
                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nTG-O0-l4y">
                                                <rect key="frame" x="0.0" y="38" width="335" height="2"/>
                                                <color key="backgroundColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                <constraints>
                                                    <constraint firstAttribute="height" constant="2" id="u9W-Yq-hih"/>
                                                </constraints>
                                            </view>
                                        </subviews>
                                        <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                        <constraints>
                                            <constraint firstItem="BhZ-fY-4k7" firstAttribute="leading" secondItem="Nnr-ax-dhk" secondAttribute="leading" id="3hK-ug-6Ys"/>
                                            <constraint firstAttribute="trailing" secondItem="nTG-O0-l4y" secondAttribute="trailing" id="54C-vF-p3i"/>
                                            <constraint firstAttribute="bottom" secondItem="nTG-O0-l4y" secondAttribute="bottom" id="7ef-y6-enL"/>
                                            <constraint firstAttribute="trailing" secondItem="j0N-ZY-V0Y" secondAttribute="trailing" id="B5b-XV-RYP"/>
                                            <constraint firstItem="j0N-ZY-V0Y" firstAttribute="centerY" secondItem="Nnr-ax-dhk" secondAttribute="centerY" id="BUL-N2-cNw"/>
                                            <constraint firstItem="nTG-O0-l4y" firstAttribute="leading" secondItem="Nnr-ax-dhk" secondAttribute="leading" id="Nib-ZA-Ihq"/>
                                            <constraint firstItem="BhZ-fY-4k7" firstAttribute="top" secondItem="Nnr-ax-dhk" secondAttribute="top" id="Rey-qG-CSa"/>
                                            <constraint firstItem="j0N-ZY-V0Y" firstAttribute="leading" secondItem="BhZ-fY-4k7" secondAttribute="trailing" constant="10" id="dx4-BK-uWj"/>
                                            <constraint firstAttribute="bottom" secondItem="BhZ-fY-4k7" secondAttribute="bottom" id="p5m-SO-CZ7"/>
                                            <constraint firstAttribute="height" constant="40" id="wBB-11-ud1"/>
                                        </constraints>
                                    </view>
                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="m6n-mP-IDR">
                                        <rect key="frame" x="0.0" y="150" width="335" height="40"/>
                                        <subviews>
                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Address 1" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="9Xe-87-5pU">
                                                <rect key="frame" x="0.0" y="0.0" width="316.5" height="38"/>
                                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                <textInputTraits key="textInputTraits"/>
                                            </textField>
                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="*" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cLO-wm-dKq">
                                                <rect key="frame" x="326.5" y="9.5" width="8.5" height="21.5"/>
                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
                                                <color key="textColor" name="RequiredFieldColor"/>
                                                <nil key="highlightedColor"/>
                                            </label>
                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0v1-IU-zJP">
                                                <rect key="frame" x="0.0" y="38" width="335" height="2"/>
                                                <color key="backgroundColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                <constraints>
                                                    <constraint firstAttribute="height" constant="2" id="xj6-r6-dVL"/>
                                                </constraints>
                                            </view>
                                        </subviews>
                                        <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                        <constraints>
                                            <constraint firstAttribute="trailing" secondItem="0v1-IU-zJP" secondAttribute="trailing" id="7ol-EC-Z7f"/>
                                            <constraint firstItem="0v1-IU-zJP" firstAttribute="top" secondItem="9Xe-87-5pU" secondAttribute="bottom" id="9Kh-vz-aHF"/>
                                            <constraint firstItem="cLO-wm-dKq" firstAttribute="leading" secondItem="9Xe-87-5pU" secondAttribute="trailing" constant="10" id="BzA-q4-AUa"/>
                                            <constraint firstItem="cLO-wm-dKq" firstAttribute="centerY" secondItem="m6n-mP-IDR" secondAttribute="centerY" id="DLF-Sg-4fb"/>
                                            <constraint firstAttribute="trailing" secondItem="cLO-wm-dKq" secondAttribute="trailing" id="Ddh-gm-hyM"/>
                                            <constraint firstItem="9Xe-87-5pU" firstAttribute="top" secondItem="m6n-mP-IDR" secondAttribute="top" id="V6F-fl-0nK"/>
                                            <constraint firstItem="0v1-IU-zJP" firstAttribute="leading" secondItem="m6n-mP-IDR" secondAttribute="leading" id="cly-NY-H6S"/>
                                            <constraint firstItem="9Xe-87-5pU" firstAttribute="leading" secondItem="m6n-mP-IDR" secondAttribute="leading" id="mCt-JT-svl"/>
                                            <constraint firstAttribute="height" constant="40" id="sGm-DQ-Zyt"/>
                                            <constraint firstAttribute="bottom" secondItem="0v1-IU-zJP" secondAttribute="bottom" id="uXh-8G-dAn"/>
                                        </constraints>
                                    </view>

                                        <rect key="frame" x="0.0" y="250" width="335" height="40"/>
                                        <subviews>
                                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Phone Number" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ykM-gm-kv4">
                                                <rect key="frame" x="0.0" y="0.0" width="316.5" height="40"/>
                                                <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                                <textInputTraits key="textInputTraits"/>
                                            </textField>
                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="*" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l86-0I-WbN">
                                                <rect key="frame" x="326.5" y="9.5" width="8.5" height="21.5"/>
                                                <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
                                                <color key="textColor" name="RequiredFieldColor"/>
                                                <nil key="highlightedColor"/>
                                            </label>
                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b1z-D7-bNt">
                                                <rect key="frame" x="0.0" y="38" width="335" height="2"/>
                                                <color key="backgroundColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                <constraints>
                                                    <constraint firstAttribute="height" constant="2" id="4ev-LH-vny"/>
                                                </constraints>
                                            </view>
                                        </subviews>
                                        <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                                        <constraints>
                                            <constraint firstItem="l86-0I-WbN" firstAttribute="leading" secondItem="ykM-gm-kv4" secondAttribute="trailing" constant="10" id="6qg-ch-5Kj"/>
                                            <constraint firstItem="ykM-gm-kv4" firstAttribute="top" secondItem="FsO-iO-UA3" secondAttribute="top" id="81o-ef-AGF"/>
                                            <constraint firstAttribute="height" constant="40" id="9mW-zj-58j"/>
                                            <constraint firstItem="ykM-gm-kv4" firstAttribute="centerY" secondItem="FsO-iO-UA3" secondAttribute="centerY" id="Amc-P7-79p"/>
                                            <constraint firstAttribute="bottom" secondItem="b1z-D7-bNt" secondAttribute="bottom" id="HBK-sg-EAD"/>
                                            <constraint firstItem="ykM-gm-kv4" firstAttribute="leading" secondItem="FsO-iO-UA3" secondAttribute="leading" id="RcY-bk-6yR"/>
                                            <constraint firstAttribute="trailing" secondItem="b1z-D7-bNt" secondAttribute="trailing" id="W2P-F3-Hlg"/>
                                            <constraint firstAttribute="trailing" secondItem="l86-0I-WbN" secondAttribute="trailing" id="efh-fE-eln"/>
                                            <constraint firstItem="l86-0I-WbN" firstAttribute="centerY" secondItem="FsO-iO-UA3" secondAttribute="centerY" id="hgs-xM-U20"/>
                                            <constraint firstItem="b1z-D7-bNt" firstAttribute="leading" secondItem="FsO-iO-UA3" secondAttribute="leading" id="qLG-Sc-NEU"/>
                                            <constraint firstAttribute="bottom" secondItem="ykM-gm-kv4" secondAttribute="bottom" id="yg9-Kg-K83"/>
                                        </constraints>
                                    </view>
                                </subviews>
                            </stackView>
                        </subviews>
                        <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
                    </view>
                </subviews>
                <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                <constraints>
                    <constraint firstAttribute="trailing" secondItem="goD-MV-xj2" secondAttribute="trailing" id="Dak-14-pgV"/>
                    <constraint firstAttribute="bottom" secondItem="goD-MV-xj2" secondAttribute="bottom" id="Eve-uT-c8i"/>
                    <constraint firstItem="goD-MV-xj2" firstAttribute="leading" secondItem="FhN-qH-KZv" secondAttribute="leading" id="HWd-e0-G4Q"/>
                    <constraint firstItem="goD-MV-xj2" firstAttribute="top" secondItem="FhN-qH-KZv" secondAttribute="top" id="ln7-n8-Afi"/>
                </constraints>
                <userDefinedRuntimeAttributes>
                    <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
                        <integer key="value" value="4"/>
                    </userDefinedRuntimeAttribute>
                </userDefinedRuntimeAttributes>
            </scrollView>
            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4cS-bG-FbJ">
                <rect key="frame" x="10" y="734" width="355" height="40"/>
                <color key="backgroundColor" name="AccentColor"/>
                <constraints>
                    <constraint firstAttribute="height" constant="40" id="MoG-YS-fiL"/>
                </constraints>
                <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
                <state key="normal" title="SAVE">
                    <color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                </state>
                <userDefinedRuntimeAttributes>
                    <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
                        <integer key="value" value="4"/>
                    </userDefinedRuntimeAttribute>
                </userDefinedRuntimeAttributes>
                <connections>
                    <action selector="saveBtnAct:" destination="meF-fr-sNf" eventType="touchUpInside" id="3cT-XX-k4z"/>
                </connections>
            </button>
        </subviews>
        <color key="backgroundColor" red="0.8862745098" green="0.8862745098" blue="0.8862745098" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
        <constraints>
            <constraint firstItem="gQb-mV-QRj" firstAttribute="trailing" secondItem="FhN-qH-KZv" secondAttribute="trailing" constant="10" id="Ke5-D5-K26"/>
            <constraint firstItem="4cS-bG-FbJ" firstAttribute="leading" secondItem="gQb-mV-QRj" secondAttribute="leading" constant="10" id="Tk0-nE-xox"/>
            <constraint firstItem="gQb-mV-QRj" firstAttribute="bottom" secondItem="4cS-bG-FbJ" secondAttribute="bottom" constant="26" id="Zor-Jg-W1u"/>
            <constraint firstItem="4cS-bG-FbJ" firstAttribute="top" secondItem="FhN-qH-KZv" secondAttribute="bottom" constant="4" id="clQ-NQ-TBp"/>
            <constraint firstItem="goD-MV-xj2" firstAttribute="width" secondItem="AwK-Dk-u5T" secondAttribute="width" constant="-20" id="h9X-0l-yIk"/>
            <constraint firstItem="FhN-qH-KZv" firstAttribute="top" secondItem="gQb-mV-QRj" secondAttribute="top" constant="64" id="i2a-Mw-TF0"/>
            <constraint firstItem="FhN-qH-KZv" firstAttribute="leading" secondItem="gQb-mV-QRj" secondAttribute="leading" constant="10" id="qEg-VO-wiQ"/>
            <constraint firstItem="gQb-mV-QRj" firstAttribute="trailing" secondItem="4cS-bG-FbJ" secondAttribute="trailing" constant="10" id="u44-kZ-irC"/>
        </constraints>
        <viewLayoutGuide key="safeArea" id="gQb-mV-QRj"/>
    </view>
    <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
    <size key="freeformSize" width="375" height="800"/>
    <connections>
        <outlet property="address1RequiredLabel" destination="cLO-wm-dKq" id="4ze-PL-To9"/>
        <outlet property="address1TextField" destination="9Xe-87-5pU" id="uMF-aw-PQZ"/>
        <outlet property="address2RequiredLabel" destination="Bnx-Sa-95p" id="882-gU-i1B"/>
        <outlet property="address2TextField" destination="zB0-7l-zSy" id="OCL-Wg-V3e"/>
        <outlet property="containerScrollView" destination="FhN-qH-KZv" id="Qgr-4M-3ah"/>
        <outlet property="emailRequiredLabel" destination="j0N-ZY-V0Y" id="H2q-yS-KW4"/>
        <outlet property="emailTextField" destination="BhZ-fY-4k7" id="ctw-kQ-7hc"/>
        <outlet property="firstNameRequiredLabel" destination="fUe-Bq-W8T" id="Pp0-BF-EIE"/>
        <outlet property="firstNameTextField" destination="fKn-8z-Pzc" id="CgT-Uw-Ixy"/>
        <outlet property="lastNameRequiredLabel" destination="7TX-E6-XLu" id="gap-4c-FWJ"/>
        <outlet property="lastNameTextField" destination="DfQ-XX-xII" id="H92-Zq-2u2"/>
        <outlet property="phoneNumberRequiredTextField" destination="l86-0I-WbN" id="CGi-on-wOu"/>
        <outlet property="phoneNumberTextField" destination="ykM-gm-kv4" id="MbB-FK-z0c"/>
        <outlet property="saveBtn" destination="4cS-bG-FbJ" id="XPF-Hi-Xtb"/>
        <outlet property="saveBtnBottomConstant" destination="Zor-Jg-W1u" id="UJd-is-ceY"/>
    </connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ssH-lW-xhj" userLabel="First Responder" sceneMemberID="firstResponder"/>
答案

我已将我的故事板粘贴到我的测试项目中并尝试调试此问题。结果发现,当ScrollViewStackView(在下面的屏幕截图中以红色突出显示)之间的视图被移除并且StackView直接放置在Container ScrollView内时,textFields变为可点击。

给出的故事板:

enter image description here

删除Container Scroll视图中的视图并直接在Container ScrollView下移动StackView。

enter image description here

删除该中间视图后的模拟器截图

enter image description here

以上是关于swift 4:我的场景中的文本字段都不可编辑的主要内容,如果未能解决你的问题,请参考以下文章

Oracle APEX 文本页面项作为 SQL 查询中的不可编辑超链接字段

Android文本字段元素可以选择,但不可编辑

在输入框中的光标后添加不可编辑的文本

如何在 Sencha Touch 中使文本字段不可编辑

如何在 Swift 中编辑或更新文本字段中的文本?

如何在 swift 4 中的另一个表视图控制器中获取该表视图单元格中的文本字段文本?