Ios 从设备获取所有图像并在uicollectionview中显示

Ios 从设备获取所有图像并在uicollectionview中显示,ios,objective-c,uicollectionview,Ios,Objective C,Uicollectionview,我想在uicollectionview中显示从设备到我的应用程序的所有图像。 并希望从uicollectionview中选择多个图像。我看了很多节目 但是我不能正确地理解它。 请帮帮我。。。 多谢各位 这个链接很好用。。。 但是,如何才能从“按钮完成”将选定的图像放入数组中。。 当我按下“完成”按钮时,数组中显示的图像如下 <UIImage: 0x7fca78772510>, {485, 303} 那么,如何在我的收藏视图中获取此图像。。帮帮我,伙计们……从图库中获取所有图像 查

我想在uicollectionview中显示从设备到我的应用程序的所有图像。 并希望从uicollectionview中选择多个图像。我看了很多节目

但是我不能正确地理解它。 请帮帮我。。。 多谢各位

这个链接很好用。。。 但是,如何才能从“按钮完成”将选定的图像放入数组中。。

当我按下“完成”按钮时,数组中显示的图像如下

<UIImage: 0x7fca78772510>, {485, 303}

那么,如何在我的收藏视图中获取此图像。。帮帮我,伙计们……

从图库中获取所有图像

查看控制器头.h文件

#import <UIKit/UIKit.h>
#include <AssetsLibrary/AssetsLibrary.h> 

@interface getPhotoLibViewController : UIViewController
{
 ALAssetsLibrary *library;
 NSArray *imageArray;
 NSMutableArray *mutableArray;
}

-(void)allPhotosCollected:(NSArray*)imgArray;

 @end
使用getAllPicture方法从照片库获取照片


或者你也可以看看这个博客

ELCImagePickerController应该可以工作。贴出你到目前为止所做的,我们可以试着解决它。看到我添加的答案,我希望你的问题得到解决@bhavin Ramani尝试过这个链接,它成功了。。。
static int count=0;

@implementation getPhotoLibViewController

-(void)getAllPictures
{
 imageArray=[[NSArray alloc] init];
 mutableArray =[[NSMutableArray alloc]init];
 NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];

 library = [[ALAssetsLibrary alloc] init];

 void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
  if(result != nil) {
   if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
    [assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];

    NSURL *url= (NSURL*) [[result defaultRepresentation]url]; 

    [library assetForURL:url
             resultBlock:^(ALAsset *asset) {
              [mutableArray addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];

              if ([mutableArray count]==count)
              {
               imageArray=[[NSArray alloc] initWithArray:mutableArray];
               [self allPhotosCollected:imageArray];
              }
             }
            failureBlock:^(NSError *error){ NSLog(@"operation was not successfull!"); } ]; 

   } 
  }
 };

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

 void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
  if(group != nil) {
   [group enumerateAssetsUsingBlock:assetEnumerator];
   [assetGroups addObject:group];
   count=[group numberOfAssets];
  }
 };

 assetGroups = [[NSMutableArray alloc] init];

 [library enumerateGroupsWithTypes:ALAssetsGroupAll
                        usingBlock:assetGroupEnumerator
                      failureBlock:^(NSError *error) {NSLog(@"There is an error");}];
}

-(void)allPhotosCollected:(NSArray*)imgArray
{
 //write your code here after getting all the photos from library...
 NSLog(@"all pictures are %@",imgArray);
}

@end