iPhone:CGBitmapContextCreateImage() 仅适用于模拟器

发布于 2024-08-04 07:35:07 字数 721 浏览 2 评论 0原文

我创建了一个使用 CoreGraphics 创建图像的应用程序。使用 iPhone 模拟器 (OS 3.1 beta3) 时,图像会出现在屏幕上,但当我在设备上运行应用程序时,图像不会出现在屏幕上。这可能是什么原因造成的?

从上下文中提取图像并将其放入图像视图中的代码片段如下所示:

    ...
    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);

提前致谢!

斯特凡

I created an app which creates an image by using 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. 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慵挽 2024-08-11 07:35:07

啊啊,这花了我很长时间。这是一个老问题,模拟器在从资源文件(图像等)加载时不区分大小写,而设备则不区分大小写。
因此,当您的文件名为 myImage.png 时,模拟器会在您将其命名为 myImage.PNG 时加载它,但 iPhone 不会。

Aaah, this took me a long time. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文