我试图将UIImageView图像保存为PNG文件,然后使用该文件作为GLTexture。 我遇到了麻烦,当我尝试在模拟器中运行我的代码时,XCode说它成功了,但模拟器崩溃而没有错误消息。有人可以帮我弄这个吗? 这里是我的代码:使用UIImagePNGRepresentation需要帮助
NSString *dataFilePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Picture.png"];
NSData *imageData = UIImagePNGRepresentation(imageView.image);
[imageData writeToFile:dataFilePath atomically:YES];
// Load image into texture
loadTexture("Picture.png", &Input, &renderer);
确保左上角的构建配置设置为Debug(例如“Simulator -3.0 | Debug”),并执行** Build> Build and Debug **。然后执行** Run> Console **来查看您的控制台。这应该会显示你的错误信息。 – Tom 2010-03-19 04:06:36
也检查dataFilePath和imageData ...他们中的任何一个NULL? Path是否有有效的字符串? – 2010-03-19 04:34:34
当我运行Build&Debug并查看控制台时,我发现问题在于我的“Picture.png”文件未找到。我怎样才能让我的UIImageView保存到我可以在我的应用程序中使用的png文件中? – user297073 2010-03-19 05:09:29