14

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:

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

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

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)

Community
  • 1
  • 1
idmean
  • 13,418
  • 7
  • 47
  • 78
  • I am getting exactly the same error, and no mention of an invalid scale factor. I am using asset catalogs with all image sizes supplied. This appears to be a definite bug. My final solution was to simply exclude the selected image, as I don't see that it is worth pursuing further. – Owen Godfrey Oct 18 '14 at 00:42
  • 1
    Duplicate from http://stackoverflow.com/questions/12672603/could-not-load-the-image-referenced-from-a-nib Answer is there. – Gabriel Cartier Oct 31 '14 at 19:02
  • @GabrielCartier Please read my question carefully, I already checked that when I asked my question. – idmean Oct 31 '14 at 19:04

7 Answers7

29

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

I solve it like this: enter image description here

Mornirch
  • 1,134
  • 9
  • 10
18

I've finally ended up using this nasty code in 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.

idmean
  • 13,418
  • 7
  • 47
  • 78
  • @RudolfAdamkovic Yeah, I know. Strange that Apple doesn't notice/fix this bug. – idmean Oct 27 '14 at 11:10
  • The whole thing is barely working. Just when I implemented your workaround, code completion for Swift stopped working. No comment. – Rudolf Adamkovič Oct 27 '14 at 11:16
  • 1
    Yes only solution I found was to set the images programatically and remove the selectedImage and the Image properties in my storyboard for each tabbaritem – Fraggle Jan 07 '15 at 17:52
5

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

NEO
  • 111
  • 2
  • 7
1

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

Solution: Select the image again in the UIImageView in storyboard

Ruud Visser
  • 3,066
  • 2
  • 18
  • 18
0

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

This solved the errors and warnings.

Credit goes to this answer from another question.

Community
  • 1
  • 1
David T
  • 2,634
  • 1
  • 15
  • 26
-1

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.

Justin Cabral
  • 495
  • 1
  • 6
  • 19
-2

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

Steven Kramer
  • 8,375
  • 2
  • 34
  • 43