UIImagePickerController獲取圖片詳細資訊
阿新 • • 發佈:2019-02-10
透過UIImagePickerController,獲取圖片名字、唯一標示UTI、路徑url
NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL]; [self getImageDetailInfo:imageURL]; //獲取圖片的詳細資訊 -(void)getImageDetailInfo:(NSURL*)imageUrl{ __block NSString* imageFileName; ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init]; [assetslibrary assetForURL:imageUrl resultBlock:^(ALAsset *myasset){ ALAssetRepresentation *representation = [myasset defaultRepresentation]; imageFileName = [representation filename]; NSLog(@"圖片路徑名:%@",imageFileName); NSLog(@"圖片UTI:%@",[representation UTI]); NSLog(@"圖片URL:%@",[representation url]); } failureBlock:nil]; }