Error: CUICatalog: Invalid asset name supplied: (null), or invalid scale factor : 2.000000

IosObjective CXcode5

Ios Problem Overview


TableViewApplication[1458:70b] CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000

Screenshot added

Getting this warning while working with TableViewController. How to rectify this error and which block is affected?

Ios Solutions


Solution 1 - Ios

This one appears when someone is trying to put nil in [UIImage imageNamed:]

Add symbolic breakpoint for [UIImage imageNamed:]Symbolic breakpoint example

Add $arg3 == nil condition on Simulator, $r0 == nil condition on 32-bit iPhone, or $x2 == nil on 64-bit iPhone.

Run your application and see where debugger will stop.

P.S. Keep in mind this also happens if image name is empty string. You can check this by adding [(NSString*)$x2 length] == 0 to the condition.

Solution 2 - Ios

This error (usually) happens when you try to load an image with [UIImage imageNamed:myImage] but iOS is not sure if myImage is really a NSString and then you have this warning.

You can fix this using:

[UIImage imageNamed:[NSString stringWithFormat:@"%@", myImage]]

Or you can simply check for the length of the name of the UIImage:

if (myImage && [myImage length]) {

    [UIImage imageNamed:myImage];
}

Solution 3 - Ios

Since the error is complaining that the name you gave is (null), this is most likely caused by calling [UIImage imageNamed:nil]. Or more specifically, passing in a variable hasn't been set, so it's equal to nil. While using stringWithFormat: would get rid of the error, I think there's a good chance it's not actually doing what you want. If the name you supply is a nil value, then using stringWithFormat: would result in it looking for an image that is literally named "(null)", as if you were calling [UIImage imageNamed:@"(null)"].

Something like this is probably a better option:

if (name) {
    UIImage *image = [UIImage imageNamed:name];
} else {
    // Do something else
}

You might want to set a breakpoint in Xcode on that "Do something else" line, to help you figure out why this code is getting called with a nil value in the first place.

Solution 4 - Ios

In Xcode 6.4, this seems to occur when using "Selected Image" for a tab bar item in the storyboard, even if it's a valid image.

enter image description here

This doesn't actually seem to set the selected state image anyway, so it needs to be defined in User Defined Runtime Attributes, and removed from the SelectedImage attribute of the Tab Bar Item

enter image description here

Solution 5 - Ios

In my case i was passing [UIImage imageNamed:@""] which caused me to show the warning. Just add breakpoints to all the lines where you have used imageNamed and the debug the line where you find the warning.

Solution 6 - Ios

This happened to me after a storyboard was split into several (the actual change happened when I was on holidays, so I don't know exactly how it was done).

After inspecting the XML of the storyboards, I found that an image reference which previously had pointed to "bottomBar" in the assets catalogue instead pointed to imageView:fFo-1g-jzs:image.

At the end of the XML file under the <resources> tag was tag named <image name="imageView:fFo-1g-jzs:image"> containing a big mutableData blob.

After resetting the image reference in the storyboard and removing the blob, the error went away.

Solution 7 - Ios

I have just fixed this error. Just check the usage of the [UIImage imageNamed:(NSString*) imageName] function. If the imageName is nil, then error occurs.

Solution 8 - Ios

You are supplying some invalid image name, so need to validate before putting it you can do any of the above ways whichever make sense for your code or like

if (iconImageName && [iconImageName length])
{

    [UIImage imageNamed:iconImageName];
}
else
{
     iconImageName.hidden = YES;
}

Hope it will help!!!!

Solution 9 - Ios

The Reason to the error is passing a nil value to the "imageNamed:" method. To avoid this, you can hide your imageView when you try to pass the nil value. The chances may occur in reusing the imageViews in UITableView or may be in scrollViews.

I avoided the warning with the below check :

UIImageView *your_image_view;
NSString *imageName;
if(imageName && imageName.length){
 your_image_view.hidden = NO;
 your_image_view.image = [UIImage imageNamed:imageName];
}
else {
 your_image_view.hidden = YES;
}

Solution 10 - Ios

I got this warning when I load image use [[UIImage imageNamed:normalStr] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal], than, I change to [UIImage imageNamed:normalStr], warning was gone.

Solution 11 - Ios

One approach is do class method swizzling to replace [UIImage imageNamed:] with your own implementation, then check the image name in your implementation. See the following:

https://stackoverflow.com/questions/3267506/how-to-swizzle-a-class-method-on-ios

I implemented this in my UIImage(Debug) category:

+ (UIImage *)db_imageNamed:(NSString *)imageName {
    if ([imageName length] == 0) {
        NSLog(@"breakpoint here");
    }
    return [self db_imageNamed:imageName];  // not a recursive call here after swizzling
}

You might want to swizzle [UIImage imageNamed:inBundle:compatibleWithTraitCollection:] as well.

Solution 12 - Ios

Maybe you can use this to confirm the "imageName" is not a "nil";Then you will leave away this warning.

 if (imageName) {
    self.imageView.image = [UIImage imageNamed:imageName];
 }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionmanish singhView Question on Stackoverflow
Solution 1 - Iostt.KilewView Answer on Stackoverflow
Solution 2 - IosFabioView Answer on Stackoverflow
Solution 3 - IosrobotspacerView Answer on Stackoverflow
Solution 4 - IosginchlyView Answer on Stackoverflow
Solution 5 - IosRahul MathurView Answer on Stackoverflow
Solution 6 - IosidrouggeView Answer on Stackoverflow
Solution 7 - IospasswindView Answer on Stackoverflow
Solution 8 - IosAshView Answer on Stackoverflow
Solution 9 - IosBharathView Answer on Stackoverflow
Solution 10 - IosMeilbnView Answer on Stackoverflow
Solution 11 - IosHaoxin LiView Answer on Stackoverflow
Solution 12 - IosTenma TobyoView Answer on Stackoverflow