Ios 不将图像的资源URL显示到UITableview单元格中?
嗨,我有一个包含以下资源URL的数组:Ios 不将图像的资源URL显示到UITableview单元格中?,ios,Ios,嗨,我有一个包含以下资源URL的数组: ( "assets-library://asset/asset.JPG?id=4D80F378-FB5A-4696-B398-2C824B625CC5&ext=JPG", "assets-library://asset/asset.JPG?id=B727299D-3FEF-4F41-B98D-B863714356EB&ext=JPG" ) ALAssetsLibraryAssetForURLResultBlock resul
(
"assets-library://asset/asset.JPG?id=4D80F378-FB5A-4696-B398-2C824B625CC5&ext=JPG",
"assets-library://asset/asset.JPG?id=B727299D-3FEF-4F41-B98D-B863714356EB&ext=JPG"
)
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref) {
UIImage *largeimage = [UIImage imageWithCGImage:iref];
cell.imageView.image = largeimage;
}
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"Can't get image - %@",[myerror localizedDescription]);
};
NSURL *asseturl = [arrDispImages objectAtIndex:indexPath.row];
library = [[ALAssetsLibrary alloc] init] ;
[library assetForURL:asseturl resultBlock:resultblock failureBlock:failureblock];
myasset is nil.
ALAssetRepresentation *rep = [myasset defaultRepresentation];
so rep is also nil.
我需要在UITableview中将此url显示为图像。如何显示此url?我的UITableview代码 通过抓取正确的单元格,在结果块内设置图像:
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref) {
UIImage *largeimage = [UIImage imageWithCGImage:iref];
NSInteger index = [arrDispImages indexOfObject:rep.url];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
cell.imageView.image = largeimage;
}
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"Can't get image - %@",[myerror localizedDescription]);
};
NSURL *asseturl = [arrDispImages objectAtIndex:indexPath.row];
library = [[ALAssetsLibrary alloc] init] ;
[library assetForURL:asseturl resultBlock:resultblock failureBlock:failureblock];
它在模拟器上工作,但在设备上不加载图像。因为ALAssetRepresentation*rep=[myasset defaultRepresentation];我的资产是零