在iPhone中显示从ALAsset检索到的URL图像我使用ALAssetFramework访问设备照片库中的文件。到目前为止,我能够访问缩略图并显示它。我想在图像视图中显示实际的图像,但是我想不出如何做到这一点。我尝试在ALAsset对象中使用URL字段,但没有成功。有人知道怎么做吗?下面是一些我能够访问缩略图并将其放在表格单元格中的代码:- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//here 'asset' represents the ALAsset object
asset = [assets objectAtIndex:indexPath.row];
//i am accessing the thumbnail here
[cell.imageView setImage:[UIImage imageWithCGImage:[asset thumbnail]]];
[cell.textLabel setText:[NSString stringWithFormat:@"Photo %d", indexPath.row+1]];
return cell;}
3 回答
有只小跳蛙
TA贡献1824条经验 获得超8个赞
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref)
{
UIImage *largeimage = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:[rep orientation]];
[delegate hiresImageAvailable:large];
}};imageWIthCGImageorientationUIImage
[UIImage imageWithCGImage:iref scale:[rep scale] orientation:[rep orientation]];
[rep fullScreenImage][rep fullResolutionImage]
元芳怎么了
TA贡献1798条经验 获得超7个赞
ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];[assetsLibrary assetForURL:self.selectedPhotos[i] resultBlock: ^(ALAsset *asset){
ALAssetRepresentation *representation = [asset defaultRepresentation];
CGImageRef imageRef = [representation fullResolutionImage];
if (imageRef) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
imageView.image = [UIImage imageWithCGImage:imageRef scale:representation.scale orientation:representation.orientation];
// ...
}} failureBlock: ^{
// Handle failure.}];failureBlocknil.
- 3 回答
- 0 关注
- 594 浏览
添加回答
举报
0/150
提交
取消
