xcode 无法加载从带有标识符的包中的笔尖引用的图像(再次)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26470171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load the image referenced from a nib in the bundle with identifier (again)
提问by kmiklas
(Xcode 6.0.1, iOS 7.1.1, iPad2)
(Xcode 6.0.1、iOS 7.1.1、iPad2)
- Added three new images to Images.xcassets
- Checked "Copy items if needed" on import dialog
- Build phases -> Copy Bundle Resources: Deleted and re-added Images.xcassets
- Checked image names to avoid case sensitivity issues
- Cleaned and rebuilt.
- Quit Xcode and restarted
- Deleted app from device for clean install
- 向 Images.xcassets 添加了三个新图像
- 在导入对话框中选中“需要时复制项目”
- 构建阶段 -> 复制捆绑资源:删除并重新添加 Images.xcassets
- 检查图像名称以避免区分大小写问题
- 清洗和重建。
- 退出Xcode并重新启动
- 从设备中删除应用程序以进行全新安装
Trying to set the image as a button background.
试图将图像设置为按钮背景。
Images are showing in the simulator, but not on a device. This leads me to believe that they're not being bundled with the app, despite the fact that I've included images.xcassets in the build.
图像显示在模拟器中,但不在设备上。这让我相信它们没有与应用程序捆绑在一起,尽管我已经在构建中包含了 images.xcassets。
I would like to check and see if the three new image sets are included, but there does not seem to be a way to drill down into images.xcassets within the "Copy Bundle Resources" branch under "Build Settings."
我想检查一下是否包含三个新的图像集,但似乎没有办法在“构建设置”下的“复制捆绑资源”分支中深入查看 images.xcassets。
I am setting the image background in storyboard by clicking on the image view, selecting the "Attributes Inspector" button, and then selecting the image name in the drop-down under "Background."
我通过单击图像视图,选择“属性检查器”按钮,然后在“背景”下的下拉列表中选择图像名称来设置故事板中的图像背景。
Other images work; it's just the newly added images that don't show up.
其他图像有效;只是新添加的图像没有显示出来。
I'm stumped... any advice?
我很难过……有什么建议吗?
回答by Ricardo Barroso
In my case the problem was that I used some .JPG images (which I know is not the ideal format but I wasn't worried with that yet since I was only doing some initial development).
就我而言,问题是我使用了一些 .JPG 图像(我知道这不是理想的格式,但我并不担心,因为我只是在做一些初步的开发)。
I converted one of the images to .PNG (using Preview), imported and the problem was resolved!
我将其中一张图像转换为 .PNG(使用预览),然后导入并解决了问题!
回答by kmiklas
It was dots in the file name!
它是文件名中的点!
The new images were named with dates appended to the end of the filename, using dots to separate month, day and year; like so:
新图像的命名是在文件名的末尾附加日期,使用点来分隔月、日和年;像这样:
- puppy.10.17.2014.png
- kitten.10.17.2014.png
- chick.10.17.2014.png
- puppy.10.17.2014.png
- 小猫.10.17.2014.png
- 小鸡.10.17.2014.png
I stripped out the dots, and named the files like so:
我去掉了点,并像这样命名文件:
- puppy.png
- kitten.png
- chick.png
- 小狗.png
- 小猫.png
- 小鸡.png
What a headache... I hope this helps someone out there in cyberspace!
真是头疼……我希望这对网络空间中的人有所帮助!
回答by ZAZ
drop a uiimageview and assign any one of these image to it to verify it shows on device or not.
删除一个 uiimageview 并将这些图像中的任何一个分配给它以验证它是否在设备上显示。