我从手机画廊使用imagepicker选择了一张图片。我可以检索所选图像的名称吗?

时间:2014-10-10 19:28:24

标签: ios iphone

我的选择图片的代码如下。

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {

    UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    self.imageview.image = chosenImage;
    NSLog(@"%@",chosenImage);
    [picker dismissViewControllerAnimated:YES completion:NULL];

}

1 个答案:

答案 0 :(得分:1)

这应该这样做:

NSURL *imagePath = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
NSString *imageName = [imagePath lastPathComponent];