CUICatalog: Can't find rendition for name: someimage@2x~ipad.png scale factor: 2 device idiom: 1 device subtype: 568

萝らか妹 提交于 2019-12-07 00:03:57

问题


I created app that perfectly worked on xcode 5. But when i run it on xcode 6 with iphone 6 simulator, it's giving me an error:

CUICatalog: Can't find rendition for name: someImage@2x~ipad.png scale factor: 2 device idiom: 1 device subtype: 568


回答1:


I know this probably isn't the answer you want, but I had the exact same problem, and simply renaming the image fixed the problem.

In other words, I copied the original file that wouldn't load to another file in the same directory, with a different name.

I then added this new file to the Xcode project and removed the first one.

I changed the code to reflect the new image name:

   // Asset Catalog problem loading this:
   //  [imgBackground setImage:[UIImage imageNamed:@"Home_BG@5g.png"]];
   [imgBackground setImage:[UIImage imageNamed:@"Home_BG-568h"]];

I slightly changed the previous developer's naming convention, to go with Home_BG-568h@2x.png.

Hope this helps someone.




回答2:


I discovered a way to load images by circumventing Apple's naming convention interpretation. Instead of using [UIImage imageNamed:], load the image as binary into an NSData and then initialize a UIImage with that data like so:

NSData* imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon@57x57" ofType:@"png"]];
UIImage* icon = [UIImage imageWithData:imageData];

Be warned, though, that there is no caching with this method and calling it multiple times will load a new image each time. If you want caching you'll have to implement that logic yourself.

The scale of the image may also not be correct. If it is a retina scale (@2x) image, you can adjust the scale of the loaded image like so:

icon = [UIImage imageWithCGImage:icon.CGImage scale:2.f orientation:UIImageOrientationUp];



回答3:


I had the same issue in my universal-app-project.

The solution has also been the renaming of all "universal-images" with are used on both or only one device (iPhone && iPad || iPhone || iPad). E.G. someimage@2x.png because no counterpart exists nor is needed...



来源:https://stackoverflow.com/questions/26249554/cuicatalog-cant-find-rendition-for-name-someimage2xipad-png-scale-factor-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!