Xcode 6 Beta 6 CUICatalog:提供的资产名称无效:(空),或无效的比例因子:2.000000

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

Xcode 6 Beta 6 CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000

iosxcode

提问by idmean

I'm getting the following errors:

我收到以下错误:

CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000
Could not load the "(null)" image referenced from a nib in the bundle with identifier "com.example.project"

I' m getting the errors since I set a "Selected Image" for a Tab Bar Item in Interface Builder:

我收到错误,因为我在界面生成器中为选项卡栏项设置了“选定图像”:

enter image description here

在此处输入图片说明

I've added the file into Xcode:

我已将该文件添加到 Xcode 中:

enter image description here

在此处输入图片说明

The setting is written into the storyboard file:

设置写入故事板文件:

<tabBarItem key="tabBarItem" title="..." image="config.png" selectedImage="config_filled.png" id="5Wh-7m-Y4H"/>

I'm using Xcode 6 Beta 6

我正在使用 Xcode 6 Beta 6

I know about Error: CUICatalog: Invalid asset name supplied: (null), or invalid scale factor : 2.000000but that doesn't help me.

我知道错误:CUICatalog:提供的资产名称无效:(空)或无效的比例因子:2.000000,但这对我没有帮助。

What could cause that the asset name is null? I've reentered the image name, I also tried with cleaning and rebuilding but the error stays (and no image appears)

什么可能导致资产名称为空?我重新输入了图像名称,我也尝试过清理和重建,但错误仍然存​​在(并且没有出现图像)

回答by Mornirch

In Xcode 6.1, some attributes in Attributes Inspector did not work, but you can use "User Defined Runtime Attributes" to solve this problem.

在 Xcode 6.1 中,Attributes Inspector 中的某些属性不起作用,但您可以使用“用户定义的运行时属性”来解决此问题。

I solve it like this: enter image description here

我是这样解决的: 在此处输入图片说明

回答by idmean

I've finally ended up using this nasty code in AppDelegate:

我终于在 AppDelegate 中使用了这个讨厌的代码:

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
((UITabBarItem *)tabBarController.tabBar.items[0]).selectedImage = [UIImage imageNamed:@"light_filled"];
((UITabBarItem *)tabBarController.tabBar.items[1]).selectedImage = [UIImage imageNamed:@"umbrella_filled"];
((UITabBarItem *)tabBarController.tabBar.items[2]).selectedImage = [UIImage imageNamed:@"config_filled"];

Hopefully Apple will fix this bug soon.

希望苹果尽快修复这个错误。

回答by NEO

Leave the "Selected Image" for a Tab Bar Item in Interface Builder emptyshould remove the warning message.

将 Interface Builder 中选项卡栏项的“Selected Image”留空应该会删除警告消息。

回答by Ruud Visser

For me the solution was to check all your UIImageViewsin story, sometimes if you delete UIImageviewand restore them with Cmd+z, the image in the UIImageViewbecomes "Unknown". I think it is a bug, since you can still see the image in the storyboard.

对我来说,解决方案是检查你所有的UIImageViews故事,有时如果你UIImageview用 Cmd+z删除和恢复它们,图像UIImageView变成"Unknown". 我认为这是一个错误,因为您仍然可以在故事板中看到图像。

Solution: Select the image again in the UIImageViewin storyboard

解决方案:UIImageView在故事板中再次选择图像

回答by David T

The solution I found was to set the entry of the tabBar image in Images.xcassets to Render As: Template Image

我找到的解决方案是将 Images.xcassets 中 tabBar 图像的条目设置为Render As: Template Image

This solved the errors and warnings.

这解决了错误和警告。

Credit goes to this answerfrom another question.

归功于另一个问题的这个答案

回答by Justin Cabral

My swift workaround because of lack of code completion was this

由于缺乏代码完成,我的快速解决方法是这样的

    let secondItem = tabBarController.tabBar.items![1] as UITabBarItem
    secondItem.selectedImage = UIImage(named: "home-selected")

This was put in the AppDelegate's didFinishLaunchingWithOptions.

这被放在 AppDelegate 的 didFinishLaunchingWithOptions 中。

回答by Steven Kramer

Try leaving off the ".png" extension, that would have fixed certain IB image loading issues in the past.

尝试不使用“.png”扩展名,它可以解决过去某些 IB 图像加载问题。