调整大小时自动布局自定义视图崩溃

时间:2014-02-03 15:46:05

标签: ios objective-c autolayout

我的自定义视图,启用了多项选择的操作表,只要更改了大小,然后添加为子视图,或者在添加后调整大小,就会崩溃。我的错误说我的约束是冲突的,但我不明白为什么。我一直在为我的所有其他自定义视图使用类似的模式(view = [Bundle loadNibNamed],view.frame = presenter.view.frame + modifiers),它们都可以正常工作,也有它们的约束。

"<NSAutoresizingMaskLayoutConstraint:0xc588920 h=--- v=--- V:[UIWindow:0xc18d290(480)]>",
"<NSAutoresizingMaskLayoutConstraint:0xc129980 h=-&- v=-&- UIView:0xd8c6210.height == SWRevealView:0xd8c5f40.height>",
"<NSAutoresizingMaskLayoutConstraint:0xd8ccb80 h=-&- v=-&- SWRevealView:0xd8c5f40.height == UIWindow:0xc18d290.height>",
"<NSAutoresizingMaskLayoutConstraint:0xc5aa660 h=-&- v=-&- UILayoutContainerView:0xc5a3d90.height == UIView:0xd8c6210.height>",
"<NSLayoutConstraint:0xda96c20 V:[UIButton:0xda99260(45)]>",
"<NSLayoutConstraint:0xda89310 V:|-(427)-[UITableView:0xe855c00]   (Names: '|':MultiSelectionSheet:0xdaac360'Select Filters' )>",
"<NSLayoutConstraint:0xda8c1d0 V:[UITableView:0xe855c00]-(1)-[UIButton:0xda99260]>",
"<NSLayoutConstraint:0xda6d520 V:[UIButton:0xda99260]-(NSSpace(20))-|   (Names: '|':MultiSelectionSheet:0xdaac360'Select Filters' )>",
"<NSAutoresizingMaskLayoutConstraint:0xc5962c0 h=-&- v=-&- MultiSelectionSheet:0xdaac360'Select Filters'.height == UILayoutContainerView:0xc5a3d90.height>"

constraints http://i58.tinypic.com/ive7ug.png layout http://i58.tinypic.com/ncmxj.png

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
    <deployment defaultVersion="1536" identifier="iOS"/>
    <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
<objects>
    <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
    <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
    <view contentMode="scaleToFill" id="1" customClass="MultiSelectionSheet">
        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
        <subviews>
            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" style="plain" separatorStyle="default" allowsMultipleSelection="YES" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="mXD-gg-Pfl">
                <rect key="frame" x="5" y="20" width="310" height="482"/>
                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
            </tableView>
            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="emp-R8-XZ7">
                <rect key="frame" x="5" y="503" width="310" height="45"/>
                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                <color key="backgroundColor" red="0.27450980390000002" green="0.76470588240000004" blue="0.83529411760000005" alpha="1" colorSpace="calibratedRGB"/>
                <constraints>
                    <constraint firstAttribute="height" constant="45" id="Ykt-VQ-0SN"/>
                </constraints>
                <state key="normal" title="DONE">
                    <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                    <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
                </state>
                <connections>
                    <action selector="dismissTable:" destination="1" eventType="touchUpInside" id="b33-Bh-apy"/>
                </connections>
            </button>
        </subviews>
        <color key="backgroundColor" white="0.26408531021897808" alpha="1" colorSpace="calibratedWhite"/>
        <constraints>
            <constraint firstItem="mXD-gg-Pfl" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="2zC-KQ-ZOt"/>
            <constraint firstItem="emp-R8-XZ7" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="5" id="6gg-Py-tQZ"/>
            <constraint firstItem="emp-R8-XZ7" firstAttribute="trailing" secondItem="mXD-gg-Pfl" secondAttribute="trailing" id="9cH-nC-BFj"/>
            <constraint firstItem="emp-R8-XZ7" firstAttribute="top" secondItem="mXD-gg-Pfl" secondAttribute="bottom" constant="1" id="MFF-2J-4nH"/>
            <constraint firstAttribute="trailing" secondItem="emp-R8-XZ7" secondAttribute="trailing" constant="5" id="OxD-y5-2uC"/>
            <constraint firstAttribute="bottom" secondItem="emp-R8-XZ7" secondAttribute="bottom" constant="20" symbolic="YES" id="cnS-12-qe0"/>
            <constraint firstItem="mXD-gg-Pfl" firstAttribute="leading" secondItem="emp-R8-XZ7" secondAttribute="leading" id="kWm-ho-P3w"/>
        </constraints>
        <simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
        <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
        <connections>
            <outlet property="dismissButton" destination="emp-R8-XZ7" id="Nwx-Xh-wGZ"/>
            <outlet property="sheetTable" destination="mXD-gg-Pfl" id="REB-gn-MlB"/>
            <outlet property="spaceAboveTable" destination="2zC-KQ-ZOt" id="uAY-xN-L78"/>
        </connections>
    </view>
</objects>

设置self.translatesAutoresizingMaskToConstrainsts = NO将允许绘制视图,但具有可疑的大小和不准确的帧大小。此外,虽然设置为NO,但在tableview上设置静态而不是动态高度会产生更多的布局冲突

0 个答案:

没有答案