xcode 图像集有一个未分配的孩子

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

image set has an unassigned child

iosswiftxcode

提问by J. Oh

I've been working on an app in Xcode for a few months now. I came back to work on it after not having looked at it for a while and suddenly, I had 174 issues and all of my images on the storyboard were replaced with question marks. The error that I keep getting is that "The image set __ has unassigned children", and in Assets.xcassets all of the images are labelled as unassigned. An example

我几个月来一直在 Xcode 中开发一个应用程序。一段时间没有看它后,我回来继续工作,突然间,我有 174 个问题,我在故事板上的所有图像都被问号替换了。我不断收到的错误是“图像集 __ 具有未分配的子项”,并且在 Assets.xcassets 中,所有图像都标记为未分配。一个例子

I don't know what to make of this, as it was all working fine a few weeks ago. Any suggestions would be much appreciated!

我不知道该怎么做,因为几周前一切正常。我们欢迎所有的建议!

回答by matt

In the asset catalog's Attributes inspector, check some checkboxes, like Universal or iPhone and iPad. Now you will see slots for the resolutions such as "1x", "2x", and "3x". Those slots are where your images need to go.

在资产目录的属性检查器中,选中一些复选框,例如通用或 iPhone 和 iPad。现在,您将看到“1x”、“2x”和“3x”等分辨率的插槽。这些插槽是您的图像需要去的地方。

回答by nithinbhaktha

I know this is an old one, but recently I got this problem after I merged 2 branches and encountered conflicts. 2 problems :

我知道这是一个旧的,但最近我在合并 2 个分支并遇到冲突后遇到了这个问题。2个问题:

  1. I got this warning and could not see anything in the attributes inspector.
  2. However I resolved the conflicts it just doesn't seem to work.
  1. 我收到此警告,但在属性检查器中看不到任何内容。
  2. 但是我解决了它似乎不起作用的冲突。

All you have to do is Clean build your Xcode. Navigate away from .xcassets. Come back to .xcassets, you should be seeing the attributes inspector now.

您所要做的就是清理构建您的 Xcode。远离 .xcassets。回到 .xcassets,您现在应该会看到属性检查器。

Check the scales option. I previously had it to single scale but now it was changed to individual scales. On changing it back I got another row in the image set stating Unassigned. I just dragged this to the single scale row. And woila !

检查比例选项。我以前有它的单一规模,但现在它改为个人规模。将其改回后,图像集中的另一行显示未分配。我只是将它拖到单个比例行。还有哇!

回答by Brent Chow

It is likely that your Image Sets are missing or have corrupt Contents.jsonfiles.

您的图像集可能丢失或Contents.json文件损坏。

Each Image Set contains a Contents.jsonfile. To see if your Image Sets have one, right click on an Image Set and click "Show in Finder". You should see your images and a Contents.jsonfile.

每个图像集包含一个Contents.json文件。要查看您的图像集是否有一个,请右键单击一个图像集,然后单击“在 Finder 中显示”。您应该会看到您的图像和Contents.json文件。

This issue with your Contents.jsonfile may have occurred by modifying, moving, or adding images outside of Xcode (e.g. through the Finder).

您的Contents.json文件的这个问题可能是通过在 Xcode 之外修改、移动或添加图像(例如通过 Finder)而发生的。

You can recreate the Contents.jsonfile by re-adding your assets in Xcode or manually creating the file. It should look something like:

您可以Contents.json通过在 Xcode 中重新添加资产或手动创建文件来重新创建文件。它应该看起来像:

{
  "images" : [
    {
      "idiom" : "universal",
      "filename" : "image.png",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "[email protected]",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "[email protected]",
      "scale" : "3x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}

回答by DrWhat

An umlaut in the file name also gives this warning.

文件名中的变音符号也会发出此警告。