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

Eli*_*hme 8 xcode objective-c uitableview uiviewcontroller ios

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

CUICatalog: Invalid asset name supplied: , or invalid scale factor: 2.000000
Run Code Online (Sandbox Code Playgroud)

我尝试使用此方法设置背景:

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

self.tableView.backgroundView = tempImageView;
Run Code Online (Sandbox Code Playgroud)

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

Kem*_*nak 0

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

UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"mypredictions_bg"]]];
Run Code Online (Sandbox Code Playgroud)