【问题标题】:Could not load the "usflag.png" image referenced from a nib in the bundle with identifier "test.icon"无法加载从带有标识符“test.icon”的包中的笔尖引用的“usflag.png”图像
【发布时间】:2015-08-26 18:14:24
【问题描述】:

我找不到收到此消息的原因:

无法加载从带有标识符的包中的笔尖引用的“usflag.png”图像...

我创建了 2 个按钮,将类型设置为自定义,选择 2 png 作为图像。在 Xcode 中一切正常。它在第一个按钮的模拟器上显示正常,但第二个按钮出现错误,但图像除外。

我在 Xcode 6.4 中获得了类似的效果,然后迁移到 7 beta 4 没有成功。

知道如何解决这么简单的事情吗?

我添加main.storyboard的源码:

                   <subviews>
                        <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="fill" contentVerticalAlignment="fill" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hFS-FI-nNd">
                            <rect key="frame" x="20" y="28" width="42" height="30"/>
                            <state key="normal" image="french_flag.png">
                                <color key="titleColor" red="0.0" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                            </state>
                        </button>
                        <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="fill" contentVerticalAlignment="fill" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FGS-JR-8HH">
                            <rect key="frame" x="20" y="66" width="42" height="30"/>
                            <state key="normal" image="usflag.png">
                                <color key="titleColor" red="0.0" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                            </state>
                        </button>
                    </subviews>

【问题讨论】:

  • 强烈建议不要编辑故事板 xml 源代码。

标签: ios xcode button


【解决方案1】:

我找到了解决方案:)

对我来说这是 Xcode 中的一个错误。

与图像相关联的按钮需要驻留在 images.xcassets 中

【讨论】:

    猜你喜欢
    • 2011-05-26
    • 2018-12-17
    • 1970-01-01
    • 2015-03-18
    • 2018-03-05
    • 2014-12-15
    相关资源
    最近更新 更多