Shi*_*tty 2 iphone uiimageview
是否可以使用UIImagePickerControllerReferenceURL在UIImageView上设置图像.传统模式使用[info objectForKey:@"UIImagePickerControllerOriginalImage"];
I tried this:
Run Code Online (Sandbox Code Playgroud)
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];
Run Code Online (Sandbox Code Playgroud)
这段代码就行了.:)
| 归档时间: |
|
| 查看次数: |
3287 次 |
| 最近记录: |