CodeGuru CodeGuru - 5 months ago 147
iOS Question

Multi Image Picker objective-c

In my application i want that user should be able to select multiple images from his gallery, but using UIImagePickerController we can select only 1 image at a time.
And as i am a fresher and don't have much knowledge of objective-c i am not able to implement Multi image picker components available on GitHub like- MAImagePicker, QBImagePicker, ELCImagePickerController.

If anyone has used any of these components kindly provide me with sample code and steps to implement that.

Answer

use ELCImagePicker https://github.com/B-Sides/ELCImagePickerController

download from github and import in your project.

add select image button

- (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];
}

get images from this methods.

- (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];
}
Comments