[iOS] 多图片选择

多图片选择控件 ,支持iOS7.0 。

BSImagePicker  github地址如下:

点击打开链接

用法如下:

- (IBAction)uploadImgBtn:(id)sender {
    BSImagePickerController *imagePicker = nil;
    [self setImagePicker:[[BSImagePickerController alloc] init]];
    [self.imagePicker setKeepSelection:YES];

    imagePicker = self.imagePicker;
    
    [self presentImagePickerController:imagePicker
                                                        animated:YES
                                                      completion:nil
                                                          toggle:^(ALAsset *asset, BOOL select) {
                                                              if(select) {
                                                                  NSLog(@"Image selected");
                                                              } else {
                                                                  NSLog(@"Image deselected");
                                                              }
                                                          }
                                                          cancel:^(NSArray *assets) {
                                                              NSLog(@"User canceled...!");
                                                              [imagePicker dismissViewControllerAnimated:YES completion:nil];
                                                          }
                                                          finish:^(NSArray *assets) {
                                                              NSLog(@"User finished :)!");
                                                              [imagePicker dismissViewControllerAnimated:YES completion:nil];
                                                          }];
}


 

选择完成后 ,得到一个 ALAsset 类型的数组 ,但是assets 数组不能直接转为UIImage 类型 ,需要转化:

 for (int i=0; i<[assets count]; i++) {
                                        ALAssetRepresentation *rep = [assets[i] defaultRepresentation];
                                        CGImageRef imgRef =[rep fullResolutionImage];
                                        UIImage *imgData= [UIImage imageWithCGImage:imgRef];
                                        [_showingImgsArr addObject:imgData];
                                    }



你可能感兴趣的:(iOS)