CUICatalog: Invalid asset name supplied: , or invalid scale factor: 2.000000

17,348

Solution 1

I made a debug class which swizzles imageNamed so that you can get a debug trace on where this is happening.

You need to install JRSwizzle to use it.

https://github.com/rentzsch/jrswizzle

#import "UIImageDebugger.h"
#import "JRSwizzle.h"


@implementation UIImageDebugger

+ (void)startDebugging
{
    static dispatch_once_t once;

    dispatch_once(&once, ^{

        NSError *error=NULL;

        [UIImage jr_swizzleClassMethod:@selector(imageNamed:)
                       withClassMethod:@selector(hs_xxz_imageNamed:)
                                 error:&error];


        if (error)
        {
            NSLog(@"error setting up UIImageDebugger : %@",error);
        }
        else
        {
            NSLog(@"!!!!!!!!!!!!!!!!!!!!  UIImage swizzle in effect - take this out for release!!");
        }


    });

}

@end

@interface UIImage (UIViewDebugger)

+ (UIImage*)hs_xxz_imageNamed:(NSString *)name;

@end


@implementation UIImage (UIViewDebugger)

+ (UIImage*)hs_xxz_imageNamed:(NSString *)name
{
    if (!name)
    {
        NSLog(@"null image name at \n%@",[NSThread callStackSymbols]);
    }

    UIImage *image=[self hs_xxz_imageNamed:name];

    if (!image)
    {
        NSLog(@"failed to make image at \n%@",[NSThread callStackSymbols]);
    }

    return image;
}

@end

Solution 2

In My case I made category for UIImageView and UITextfied, In That, sometimes I don't need an image, that time I supplied @"" (i.e. Null string), it occurs problem, after some R&D I supply just "nil" instead of @"", it solves my warning, so maybe this type of warning occurs while not get proper image.

Share:
17,348
Elias Rahme
Author by

Elias Rahme

Multimedia Engineer - IOS developper

Updated on June 04, 2022

Comments

  • Elias Rahme
    Elias Rahme almost 2 years

    I have a UiVIewController in which i have dragged a table view and put all the needed connections like delegate and data source and it works just fine, everything is great. I tried to set a background to this table view , and the i got this weird error

    CUICatalog: Invalid asset name supplied: , or invalid scale factor: 2.000000
    

    I tried to set the background using this method :

    UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mypredictions_bg.png"]];
    [tempImageView setFrame:self.tableView.frame];
    
    self.tableView.backgroundView = tempImageView;
    

    What am i missing ? I checked the name of the picture is correct

  • puppybits
    puppybits over 9 years
    You don't need to swizzle methods you can set a break point at that method and inspect the variables. In the breakpoint panel (cmd+7) click the little + at the bottom and add a symbolic breakpoint with name "+[UIImage imageNamed:]". You can even set conditions to break and output commands to lldb when the break point is hit.
  • Confused Vorlon
    Confused Vorlon over 9 years
    @puppybits - how would you set the conditions? I'm familiar with setting up conditions within the context of my own code - but with the symbolic breakpoint, I'm not sure how I access the input (name) or the return value to query them.
  • Boris Suvorov
    Boris Suvorov about 9 years
    @ConfusedVorlon, this is great. Incorporated this into the project to help us find all the places when we remove resource files from the project by mistake.