是否可以使用 UIImageView 设置图像 UIImagePickerControllerReferenceURL 。传统的模式是使用 [信息 objectForKey:@"UIImagePickerControllerOriginalImage"];
I tried this:
theImageView.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[info objectForKey:UIImagePickerControllerReferenceURL]]];
但是 UIImageView 上没有设置图像。
请帮忙。
最佳答案
NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:referenceURL resultBlock:^(ALAsset *asset)
{
UIImage *copyOfOriginalImage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
theImageView.image = copyOfOriginalImage;
}
failureBlock:^(NSError *error)
{
// error handling
}];
[library release];
这段代码成功了。 :)
关于iphone - 使用 UIImagePickerControllerReferenceURL 在 UIImageView 上设置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8343557/