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

我想在uicollectionview中将设备中的所有图像显示到我的应用程序。 并希望从uicollectionview中select多个图像。 我看过一些节目。 ELCImagePickerController

但我不能正确地得到它。 请帮助我…谢谢

这个链接工作正常… 多选ImagePicker,但我怎么能从button完成选定的图像到数组.. 选定的图像

当我按下这样的arrays中显示的完成button图像….

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

所以,我怎么能得到这个图像在我的collections查看..帮助我们球员….

从图库中获取所有图像

View Controller标题(.h)文件

 #import <UIKit/UIKit.h> #include <AssetsLibrary/AssetsLibrary.h> @interface getPhotoLibViewController : UIViewController { ALAssetsLibrary *library; NSArray *imageArray; NSMutableArray *mutableArray; } -(void)allPhotosCollected:(NSArray*)imgArray; @end 

实施文件

声明全局计数variables为

 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 

使用getAllPicture方法从照片库中获取照片。

或者你可以看看这个博客http://mutiselectimagepicker.blogspot.in/2014/08/imageselect-to-allow-multiple-selection.html