多图像选择器目标-c

时间:2016-06-07 09:04:06

标签: ios objective-c elcimagepickercontroller

在我的应用程序中,我希望用户应该能够从他的图库中选择多个图像,但是使用UIImagePickerController,我们一次只能选择1个图像。 由于我是一个更新鲜,并且对Objective-c没有太多了解,我无法在GitHub上实现多图像选择器组件,如MAImagePicker,QBImagePicker,ELCImagePickerController。

如果有人使用过任何这些组件,请向我提供示例代码和实现它的步骤。

1 个答案:

答案 0 :(得分:5)

使用ELCImagePicker https://github.com/B-Sides/ELCImagePickerController

从github下载并导入您的项目。

添加选择图片按钮

- (IBAction)selectImg:(id)sender
{
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initImagePicker];
    elcPicker.maximumImagesCount = 100; //Set the maximum number of images to select to 100
    elcPicker.returnsOriginalImage = YES; //Only return the fullScreenImage, not the fullResolutionImage
    elcPicker.returnsImage = YES; //Return UIimage if YES. If NO, only return asset location information
    elcPicker.onOrder = YES; //For multiple image selection, display and return order of selected images
    elcPicker.mediaTypes = @[(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie]; //Supports image and movie types
    elcPicker.imagePickerDelegate = self;
    [self presentViewController:elcPicker animated:YES completion:nil];
}

从这些方法中获取图像。

- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
{
    [self dismissViewControllerAnimated:YES completion:nil];

    for (NSDictionary *dict in info)
    {
        if ([dict objectForKey:UIImagePickerControllerMediaType] == ALAssetTypePhoto)
        {
            if ([dict objectForKey:UIImagePickerControllerOriginalImage])
            {
                UIImage* image=[dict objectForKey:UIImagePickerControllerOriginalImage];
                [arrImgs addObject:image];
            }
        }
    }

}

- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}