iOS   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了从iphone照片库中获取照片并在表格视图中显示大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我想在表格视图中显示照片库中的所有图像.我可以通过assetsLibrary访问所有图像,但无法在表格中显示它们.我没有得到任何错误,但仍然不知道发生了什么. NSMutableArray *assets = [[NSMutableArray alloc]init]; ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init]; [libr
@H_403_4@
我想在表格视图中显示照片库中的所有图像.我可以通过AssetsLibrary访问所有图像,但无法在表格中显示它们.我没有得到任何错误,但仍然不知道发生了什么.

NSMutableArray *assets = [[NSMutableArray alloc]init];

ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init];

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup   *group,BOOL *stop){

         if(group != NULL){

        [group enumerateAssetsUsingBlock:^(ALAsset *result,NSUInteger index,BOOL *stop){

                if(result != NULL){
                [assets addObject:result];
                }else NSLog(@"NO photo");;
          }];
     }
}


failureBlock:^(NSError *error){NSLog(@"Error");}];

表视图的数据源方法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath{

NSString *identifier = @"id";

UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:identifier];  

if(cell == NULL){

    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reusEIDentifier:identifier];
}

[cell.imageView setImage:[UIImage imageWithCGImage:[[assets objectATindex:indexPath.row]thumbnail]]];

[cell textLabel].text = @"Photo";

return cell;

}

请求帮助我做错了….

感谢帮助

@H_403_4@

解决方法

可以参以下链接解决您的问题

http://agilewarrior.wordpress.com/tag/alassetslibrary/

@H_403_4@ @H_403_4@
@H_403_4@
@H_403_4@

大佬总结

以上是大佬教程为你收集整理的从iphone照片库中获取照片并在表格视图中显示全部内容,希望文章能够帮你解决从iphone照片库中获取照片并在表格视图中显示所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。