xcode CUICatalog:提供的资产名称无效:或无效的比例因子:2.000000

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

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

iosobjective-cxcodeuitableviewuiviewcontroller

提问by Elias Rahme

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

我有一个 UiVIewController,我在其中拖动了一个表视图并放置了所有需要的连接,如委托和数据源,它工作得很好,一切都很好。我试图为这个表视图设置背景,但我得到了这个奇怪的错误

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

我错过了什么?我检查了图片名称是否正确

回答by Confused Vorlon

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

我制作了一个调试类,它混合了 imageNamed 以便您可以获得有关发生这种情况的调试跟踪。

You need to install JRSwizzle to use it.

您需要安装 JRSwizzle 才能使用它。

https://github.com/rentzsch/jrswizzle

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

回答by g212gs

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.

在我的情况下,我为 UIImageView 和 UITextfied 创建了类别,在那,有时我不需要图像,那次我提供了 @""(即空字符串),它出现问题,经过一些 R&D 我只提供“nil”而不是@"",它解决了我的警告,所以可能会在没有获得正确图像的情况下发生这种类型的警告。

回答by Kemal Can Kaynak

If your image type is png, you don't have to replace it end of the image filename because default XCode image type is already png. Try this;

如果您的图像类型是 png,则不必在图像文件名的末尾替换它,因为默认的 XCode 图像类型已经是 png。尝试这个;

UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"mypredictions_bg"]]];

回答by bdv

In my case, was directing to the wrong viewController. I was directing to the viewController that handled the content of a page based ViewController, instead of linking to the viewController in which the pageContentViewController as well as the PageViewController were linked. Hope this helps.

就我而言,是指向错误的 viewController。我指向处理基于页面的 ViewController 内容的 viewController,而不是链接到链接 pageContentViewController 和 PageViewController 的 viewController。希望这可以帮助。