如何添加到 xcode 中的媒体库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14129001/
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
how to add to the media library in xcode?
提问by user1917407
I'm a beginning programmer, so sorry if this sounds stupid. I understand that I have to put the image into Xcode through the media library... but where is the media library? I threw the image file into the folder I made when I created the project but it's not showing up. I have the same image in there in 2 formats: PNG and JPEG. Where is the location of the "Media Library"?
我是一个初级程序员,如果这听起来很愚蠢,那么抱歉。我知道我必须通过媒体库将图像放入 Xcode 中……但是媒体库在哪里?我把图像文件扔到我创建项目时创建的文件夹中,但它没有显示出来。我在那里有两种格式的相同图像:PNG 和 JPEG。“媒体库”的位置在哪里?
回答by DrummerB
What do you mean with Media Library? The pane in Interface Builder on the bottom right? That just lists all the media items that are part of your current project or workspace.
媒体库是什么意思?Interface Builder 中右下角的窗格?这只是列出了属于您当前项目或工作区的所有媒体项目。
You have to add the images to your project, if you want to use them in your app. The easiest way is to drag them in one of the Groups in Xcode's Project Navigator tab on the left side. Make sure you check your target (this will make Xcode copy the images into your app's resources on compile time).
如果您想在您的应用程序中使用它们,您必须将图像添加到您的项目中。最简单的方法是将它们拖到左侧 Xcode 的 Project Navigator 选项卡中的组之一中。确保检查您的目标(这将使 Xcode 在编译时将图像复制到您的应用程序资源中)。
回答by sarojkumar rout
If you have the png or jpg, first, you need to create an imageset and then restart xcode, it would be available inside the media library. To create an image set, you need to select the Assets.xcassets in the left navigation pane, and then in the tool bar select the editor -> Add Assets -> New Image Set. Give a name to your image and select render as Template Image.
如果您有 png 或 jpg,首先,您需要创建一个图像集,然后重新启动 xcode,它将在媒体库中可用。要创建图像集,您需要在左侧导航窗格中选择 Assets.xcassets,然后在工具栏中选择编辑器 -> 添加资产 -> 新建图像集。为您的图像命名并选择渲染为模板图像。