0
我已经使用下面的代码将选取的图像存储到文档目录中。不能在文档目录中看到选取的图像
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
UIImage *img = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImagePNGRepresentation(img);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setDateFormat:@"yyyy-MM-dd,HH:mm:ss"];
NSString *imageName = [NSString stringWithFormat:@"photo-%@.png",
[dateFormatter stringFromDate:[NSDate date]]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
[imageData writeToFile:fullPathToFile atomically:YES];
imageView.image=image;
NSLog(@"path %@",fullPathToFile);// shows the complete image path
[self dismissModalViewControllerAnimated:YES];
}
可惜我看不到在文件目录中摄取的图像,我用“fullPathToFile”可变内容,浏览器网址是否可用或者not..But它不是.. 问你的帮助。
感谢..但图像不能在打印路径查找.. ;-( – 2013-02-11 12:04:48
你在模拟器测试它检查您的文件?目录在模拟器中,如果图像文件被创建或没有 – 2013-02-11 12:09:59
是啊,我检查了网址... 用户/用户名/库/应用程序支持/ iPhone模拟器/ 6.0 /应用程序/ F3535242-FF08-417B-BD08-4F2EAD1D27A2/Documents/ – 2013-02-11 12:18:16