我想用相机拍照并保存在文档目录中,名称和图像在 UITableViewCell 中查看。
如果我选择任何一行,则相应的行图像将转到带有名称和图像的下一个 View 。
请给出你的想法、建议和引用代码。
Best Answer-推荐答案 strong>
试试这个方法将 UIImage 存储在本地目录中...
- (void)imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info {
UIImage *pickedImage = [info objectForKey:UIImagePickerControllerEditedImage];
[self addImage:pickedImage toCacheWithIdentifier"NAME OF THE IMAGE"];
}
- (void)addImageUIImage *)image toCacheWithIdentifierNSString *)identifier {
NSString *folderPath = @"LOCAL DIRECTORY PATH ";
if(![[NSFileManager defaultManager] fileExistsAtPath:folderPath isDirectory:nil]) {
[[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:YES attributes:nil error:nil];
}
NSString *fileName = [NSString stringWithFormat"%@.png",identifier];
fileName = [folderPath stringByAppendingPathComponent:fileName];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:fileName atomically:YES];
}
在点击表格 View 单元格时检索图像,从 didselectRowAtIndexPath .... 调用此方法
- (UIImage *)imageFromCacheWithIdentifierNSString *)identifier {
NSString *folderPath = @"LOCAL DIRECTORY PATH ";
NSString *fileName = [NSString stringWithFormat"%@.png",identifier];
fileName = [folderPath stringByAppendingPathComponent:fileName];
if([UIImage imageWithContentsOfFile:fileName]) {
return [UIImage imageWithContentsOfFile:fileName];
}
return nil;
}
关于iphone - 相机照片保存在带有名称的文件夹中,并在 iphone 的 tableview 中查看,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/19378947/
|