迁移到资产目录后,情节提要板不显示资产
问题描述:
将图像资源迁移到资产目录后,该应用程序会构建并正确运行,但资产不会显示在Xcode的故事板上.
After migrating image resources to an Asset Catalog the app builds and runs correctly but the assets don't show up in Xcode's storyboard.
答
在我的情况下,这是因为我在Storyboard中使用了完整的资产名称,包括文件扩展名(即".png").
In my case this occurred because I used the full asset name including file extension (i.e. '.png') in Storyboard.
但是,资产名称必须与资产目录中的图像集名称相匹配:
However, the name for the asset needs to match the name of the Image Set in the Asset Catalog:
因此,通过从情节提要中的图像名称中删除".png",就解决了该问题.
So by removing '.png' from the image name in Storyboard it solved the problem.