简体   繁体   English

Xcode6图像视图+资产目录。 图像没有显示

[英]Xcode6 image view + Asset Catalog. Image not showing

iOS Newbie here. iOS新手在这里。 After the announcement of Xcode 6 and SWIFT, I decided to give it a try. 宣布Xcode 6和SWIFT后,我决定尝试一下。

Now I am three days into iOS development and found a very strange problem. 现在我进入iOS开发三天,发现一个非常奇怪的问题。

Problem: On a empty project with only 1 ImageView control, I can't figure out how to display a PNG image. 问题:在只有1个ImageView控件的空项目中,我无法弄清楚如何显示PNG图像。

Here is what I did: 1) Create a single view project. 这是我做的:1)创建一个单一的视图项目。 2) Create a Asset Catalog, add image set, add PNG image. 2)创建资产目录,添加图像集,添加PNG图像。 3) In storyboard, drag Image View Control into the board. 3)在故事板中,将Image View Control拖到板上。
4) Assign image & background color to Image View 4)将图像和背景颜色分配给图像视图 在此输入图像描述

Now hit run and simulator shows only the image background but not the image. 现在点击运行并且模拟器仅显示图像背景而不显示图像。

Xcode 6, target iOS7.0, ipad 2 simulator(7.1). Xcode 6,目标iOS7.0,ipad 2模拟器(7.1)。

Tested the same procedure in Xcode 5 and the image shows correctly. 在Xcode 5中测试了相同的过程,图像显示正确。 However, I wish to learn SWIFT + Xcode 6. Using Xcode 5 isn't really a solution. 但是,我希望学习SWIFT + Xcode 6.使用Xcode 5并不是一个真正的解决方案。

Here is the project package if you care to test it. 如果你想测试它,这是项目包。

I've had a similar problem, but for an Objective-C project. 我有一个类似的问题,但对于Objective-C项目。 I found this "problem" listed in the release notes: 我发现发行说明中列出了这个“问题”:

"Images from asset catalogs in projects with a minimum deployment target of iOS 7 or OS X 10.9 will be available when running on iOS 8 and OS X 10.10, but not iOS 7 and OS X 10.9." “在iOS 8和OS X 10.10上运行时,可以使用iOS 7或OS X 10.9最低部署目标的项目中的资产目录图像,而不是iOS 7和OS X 10.9。”

Which I took to mean that you will not see the images if the target device/simulator is not running iOS 8. I've partially confirmed this by deleting the images from the Images.xcassets and copying them into the project as files, then they get loaded and displayed correctly. 我认为如果目标设备/模拟器没有运行iOS 8,你就不会看到图像。我已经通过删除Images.xcassets中的图像并将它们作为文件复制到项目中来部分证实了这一点,然后他们加载并正确显示。

So, I take this mean that I should avoid using the Images asset catalog for iOS 7 targets for this release and just copy the images in as files. 所以,我认为我应该避免在此版本中使用适用于iOS 7目标的图像资产目录,只需将图像复制为文件即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM