我想使用Objective-C
为iPhone图库使用didFinishPickingMediaWithInfo
获取图像路径
答案 0 :(得分:1)
您可以在 didFinishPickingMediaWithInfo 方法中从信息 dic获取所有图像信息。您可以使用 UIImagePickerControllerReferenceURL 作为所选图像的referenceURL。
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@"Image Dic Description :%@",info.description);
}
你从它下面得到钥匙:
UIImagePickerControllerCropRect
UIImagePickerControllerEditedImage
UIImagePickerControllerMediaType
UIImagePickerControllerOriginalImage
UIImagePickerControllerReferenceURL
答案 1 :(得分:0)
您必须创建路径并将该图像写入应用程序文档文件夹中。
NSString * imageName = [NSString stringWithformat:@"sample_img.png"]; // Imgae name
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
NSString* pathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
NSLog(@"Image Path=%@",pathToFile); //This will print the path in console
[imageData writeToFile:fullPathToFile atomically:NO];