【问题标题】:Putting Image View into Collection View Cell causes IBTool to give warning将图像视图放入集合视图单元格会导致 IBTool 发出警告
【发布时间】:2013-12-04 14:23:43
【问题描述】:

我正在使用 Xcode 5。

由于某种原因,如果我将图像视图放入集合视图单元格中,我会收到以下警告

2013-11-20 06:21:39.987 Interface Builder Cocoa Touch Tool[1237:303] 
WARNING: 
Reason:     Could not find layout engine view for view's (<UIView: 0x102939b0; frame = (-20 -20; 90 90); autoresize = RM+BM; layer = <CALayer: 0x10288690>>) coordinate space view <UIView: 0x1028aaf0; frame = (0 0; 50 50); autoresize = W+H; gestureRecognizers = <NSArray: 0x10298620>; layer = <CALayer: 0x10299730>>. But the canvas coordinateSpaceView is view's superview, so we are assuming the same in the layout engine.
File:       /SourceCache/IBAutolayoutFoundationIOS/IBAutolayoutFoundation-3430/Framework/Classes/Arbitration/IBAutolayoutEngine.m:335
Method:     -[IBAutolayoutEngine layoutFrameForView:inCoordinateSpaceOfView:]

这些警告会污染编译输出,有时我会错过重要消息。

我怎样才能摆脱它?

这是我的故事板的 sn-p 导致它:

<collectionView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" restorationIdentifier="zzzzz" minimumZoomScale="0.0" maximumZoomScale="0.0" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="esr-tl-gXA">
    <rect key="frame" x="80" y="104" width="160" height="207"/>
    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
    <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="dJb-8s-18M">
        <size key="itemSize" width="50" height="50"/>
        <size key="headerReferenceSize" width="0.0" height="0.0"/>
        <size key="footerReferenceSize" width="0.0" height="0.0"/>
        <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
    </collectionViewFlowLayout>
    <cells>
        <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="A9w-gO-BzK">
            <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
            <autoresizingMask key="autoresizingMask"/>
            <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
                <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
                <autoresizingMask key="autoresizingMask"/>
                <subviews>
                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="55Z-yW-7Qm">
                        <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                    </imageView>
                </subviews>
                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
            </view>
        </collectionViewCell>
    </cells>
</collectionView>

【问题讨论】:

    标签: ios interface-builder xcode5 autolayout


    【解决方案1】:

    我已经为这个问题苦苦挣扎了一段时间(得到了类似的 ibtool 错误和异常),并尝试了以下所有方法:

    1. 检查了所有视图被报告为具有“错误”关系的 XIB 文件。还按照ibtool异常信息中的建议分析了console.app中的崩溃报告。我的布局没有任何问题。
    2. 删除了包含 UICollectionViewCell 和 UICollectionView 的 XIB 文件。然后在 Xcode5 中从头开始重新创建它们。
    3. 清理 + 重建。
    4. 重新启动 Xcode,重新启动 iOS 模拟器。
    5. 删除Xcode:~/Applications/Xcode和~/Library/Developer/Xcode,然后重新生成最新的Xcode,重启机器。
    6. 将项目迁移到 Storyboard(即将几乎所有 XIB 文件替换为单个故事板。这个工具工作量很大)。

    即使在迁移到 Storyboard 之后,偶尔也会弹出相同的错误,但后来我发现以下方法可以解决它:

    1. 重置 iOS 模拟器(iOS 模拟器 > 重置内容和设置)
    2. 清理 Xcode 项目,然后重新启动 Xcode。
    3. 重启 iOS 模拟器。

    这当然是苹果,我和他们一起养的。

    【讨论】:

    • 我也收到“找不到布局引擎视图”警告,但构建完成时 ibtool 出现错误,我假设两者是相关的。清理和重新启动 Xcode 没有帮助。也不会杀死整个 DerivedData 目录。
    • 这是一个 XCode 错误,我已在 bugreporter.apple.com 上提出。此后不久,Apple 将其作为副本关闭。所以他们知道这一点,并希望能在下一个 SDK 中修复它......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多