简体   繁体   English

iPhone:CGBitmapContextCreateImage()仅在模拟器中有效

[英]iPhone: CGBitmapContextCreateImage() only works in Simulator

I created an app which creates an image by using CoreGraphics. 我创建了一个使用CoreGraphics创建图像的应用程序。 The images appears on the screen when using the iPhone Simulator (OS 3.1 beta3) but not when I run the application on the device. 当使用iPhone Simulator(OS 3.1 beta3)时,图像出现在屏幕上,但是当我在设备上运行应用程序时,图像却没有出现。 What could be the cause of this? 这可能是什么原因?

The code snipped which extracts the image from the context and puts it in an image view looks like this: 剪切的代码从上下文中提取图像并将其放入图像视图中,如下所示:

    ...
    ImageResultViewController *resultViewController = [[ImageResultViewController alloc] initWithNibName:nil bundle:nil];
    // Extract resulting image from context
    UIImage *renderedImage = [[UIImage imageWithCGImage:CGBitmapContextCreateImage(context)] retain];
    [resultViewController presentImage:renderedImage];
    [renderedImage release];
    [self.navigationController pushViewController:resultViewController animated:YES];
    [resultViewController release];
    CGContextRelease(context);

Thanks in advance! 提前致谢!

Stefan 斯特凡

Aaah, this took me a long time. Aaah,这花了我很长时间。 It was the old issue that the simulator is case-insensitive when loading from resource files (images, ...) and the device is not. 从资源文件(图像等)加载时模拟器不区分大小写,而设备则不区分大小写是一个老问题。 So when your file is named myImage.png , the simulator will load it when you name it myImage.PNG but iPhone will not. 所以,当你的文件被命名为myImage.png,模拟器将加载它,当你的名字myImage.PNG但iPhone不会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM