Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Kieran Robinson
Kieran Robinson
9,411 Points

More than one image...

Ash Furrow, i am currently working on an app that has a 'checklists' page. i want the user to be able to add 3 images maximum to each checklist item. However i can't find anything on the UIImagePickerController that allows me to pick 3 images at a time?

4 Answers

Ash Furrow
STAFF
Ash Furrow
Treehouse Guest Teacher

hmm. The built-in iOS image picker controller does not support multiple image selection, AFAIK. You'll have to use a third-party, open source library. Looks like there are lots to pick from – I'd start looking here.

Kieran Robinson
Kieran Robinson
9,411 Points

Thanks for clarification! saves me spending ages syphoning through apple docs! I will have a look over that one later, thanks again! will post how i got on!

Kieran Robinson
Kieran Robinson
9,411 Points

Ash Furrow, i will need to add 2 extra 'imageData' attributes within my coreData file right? in order to allow 3 images to be saved at one time?

Kieran Robinson
Kieran Robinson
9,411 Points

Hi Ash Furrow, I have implemented the ELCImagePicker in order to select 3 images at a time. Currently the first image is being set and i am only logging the other two. In order to set the other two images into their respective image views i am using the -(void)setPickedImage:(UIImage *)pickedImage method, but this is only for the first pickedImage, and won't allow me to use pickedImage2 and pickedImage3

How do i add the other two images?

Kieran Robinson
Kieran Robinson
9,411 Points

Never mind my last comment i have that bit figured out. The last thing i now need to get my head around is this. This is my current method. -(void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info { NSMutableArray *images = [NSMutableArray arrayWithCapacity:[info count]];

for (NSDictionary *dict in info) {

    UIImage *image = [dict objectForKey:UIImagePickerControllerOriginalImage];
    [images addObject:image];
}
self.pickedImages = images;

pickedImages is a mutable array that the picked images are added to (3 maximum). I have 3 imageViews called pickedImageView1, pickedImageView2 and pickedImageView3 of which i am setting the images in the setPickedImage method (for all three picked images).

That all works perfectly, in that i can add 3 images, save them and they are reloaded on upon editing the page. However if i have, for example, 2 images set, and i go to add another image (should go into pickedImageView3) it replaces the image in pickedImageView1. how do i check if the imageViews are already in use and add the image to the third one as apposed to replacing the first? Hope that makes sense Ash Furrow, Kieran