- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{ NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; //1.选择的是图片资源 if ([mediaType isEqualToString:@"public.image"]) {
if (img !=nil) {
//获取图片的名字
__block NSString* imageFileName;
NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];
NSLog(@"imgurl:%@",imageURL);
__weak typeof(self) weakSelf = self;
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *representation = [myasset defaultRepresentation];
imageFileName = [representation filename];
};
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:imageURL
resultBlock:resultblock
failureBlock:nil];
}
}}