我在OS X上的Pixelmator中创建了一个png文件,我想在我的iOS应用程序中使用它。此图像在OSX中显示正常,当我使用文件的URL创建NSData对象时,调试器中的quicklook预览也会完美地显示图像,但是当我尝试使用以下内容创建UIImage时
NSURL* imageURL = [[NSBundle mainBundle] URLForResource: name withExtension: @"png"];
NSData* data = [NSData dataWithContentsOfURL: imageURL]; //at this line, quicklooking "Data" shows the image I want
image = [UIImage imageWithData: data]; //this is the relevant line, where the failure is logged
if (!image) {
//this has the same result
NSURL* imageURL = [[NSBundle mainBundle] URLForResource: @"imageNotFound" withExtension: @"png"];
NSData* data = [NSData dataWithContentsOfURL: imageURL];
image = [UIImage imageWithData: data];
}
}
我收到此错误消息
<Error>: CGImageCreateWithImageProvider: invalid image size: 0 x 0.
最后的皱纹;当用作GLKTextureLoader的纹理时,打印此错误的类似图像会完美显示。