我正在使用这个精彩的教程为带有 phonegap 的 IOS 创建一个类似 Instagram 的应用程序
它很好用,但是当我尝试下载、存储照片并将照片传递给插件时,我收到错误消息
我的错误是:
Dec 19 14:36:58 iPhone-of-your-home Imagefilter [17418] <Error>: ImageIO: CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource failed with error code -15.
我的插件代码是:
-(void)none:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options
{
//I think that here is the problem
NSString *filePath = [options objectForKey:@"image"];
// CREATE NSURL
NSURL *fileNameAndPath = [NSURL URLWithString:filePath];
NSLog(@"FILE PATH: %@",fileNameAndPath);
// DEFINE OUR CIImage
CIImage *beginImage =
[CIImage imageWithContentsOfURL:fileNameAndPath];
CIContext *context = [CIContext contextWithOptions:nil];
// DO ALL MODIFICATIONS HERE.
CGImageRef cgimg =
[context createCGImage:beginImage fromRect:[beginImage extent]];
...
...
}
正如我在捕获图像并传递它时从控制台看到的那样,它的 URL 如下:
file://localhost/var/mobile/Applications/EFDAF913-6287-4B46-B2FE-F9B0D3349DDF/tmp/cdv_photo_031.jpg
虽然我下载的文件有一个类似的 URL
/var/mobile/Applications/EFDAF913-6287-4B46-B2FE-F9B0D3349DDF/Documents/img18.png