在界面生成器 UIImageView 中从 Xcode“文件夹参考”访问图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4159178/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:54:47  来源:igfitidea点击:

Accessing Images from Xcode "Folder Reference" in Interface Builder UIImageView

iphonexcodeinterface-builderuiimageview

提问by james_womack

Possible Duplicate:
iPhone Interface Builder - Moved resources to sub-directory, now IB can't see them!

可能的重复:
iPhone Interface Builder - 将资源移动到子目录,现在 IB 看不到它们!

There is a Folder Reference that contains my images in Xcode. I want to load an image from that image into an UIImageView insideof Xcode rather than programmatically, so I can visually design the interface.

有一个文件夹参考,其中包含我在 Xcode 中的图像。我想将该图像中的图像加载到Xcode内部的 UIImageView 中,而不是以编程方式,以便我可以直观地设计界面。

Not only do the images in that folder not appear in the Image View->Image drop-down menu in Interface Builder, the images don't show up when I manually type in the path.

该文件夹中的图像不仅不会出现在 Interface Builder 的“图像视图”->“图像”下拉菜单中,而且当我手动输入路径时,图像也不会显示。

回答by Ryan

Try putting the images into the Resources folder in Xcode instead of your folder reference. Also, make sure the images have been added to the target from which you want to be able to access the images. To do this:

尝试将图像放入 Xcode 中的 Resources 文件夹,而不是您的文件夹引用。此外,请确保图像已添加到您希望能够访问图像的目标中。去做这个:

  1. Select the image in the Groups & Files column in Xcode
  2. Right-click on the image and select Get Info
  3. In the Info window that comes up, select the Targets tab
  4. Check the boxes next to the targets that you need to be able to access this file from
  1. 在 Xcode 的 Groups & Files 列中选择图像
  2. 右键单击图像并选择获取信息
  3. 在出现的信息窗口中,选择目标选项卡
  4. 选中您需要能够从中访问此文件的目标旁边的框