Xcode - 获取图像名称或扩展名

时间:2014-12-18 10:18:46

标签: objective-c ios8 xcode6

如何获取从源类型UIImagePickerControllerSourceTypeCamera的UIImagePickerController中选取的图像的图像名称(或图像扩展格式)?

2 个答案:

答案 0 :(得分:2)

试试这个:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{
    NSURL *imagePath = [info objectForKey:@"UIImagePickerControllerReferenceURL"];
    NSString *imageName = [imagePath lastPathComponent];
}

答案 1 :(得分:1)

看看下面的代码

NSLog(@"%@",[[info[0] objectForKey:UIImagePickerControllerReferenceURL] pathExtension])//image extention
NSLog(@"%@",[[info[0] objectForKey:UIImagePickerControllerReferenceURL] pathComponents])//image name