Error: CUICatalog: Invalid asset name supplied: (n

2019-01-10 06:15发布

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?

12条回答
We Are One
2楼-- · 2019-01-10 06:38

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];
 }
查看更多
forever°为你锁心
3楼-- · 2019-01-10 06:42

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!!!!

查看更多
老娘就宠你
4楼-- · 2019-01-10 06:52

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.

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-10 06:52

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:

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.

查看更多
forever°为你锁心
6楼-- · 2019-01-10 06:53

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.

查看更多
▲ chillily
7楼-- · 2019-01-10 06:56

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.

查看更多
登录 后发表回答