2

I am trying to simply enable picking multiple images from photolibrary using the UIImagePickerController, I wish I can add a subview on bottom of the photo picker so it look something like this app does:

It there a simple way you can do it? My code currently only pops the images in a standard way but I only dismiss the controller when loaded 6 images

The important thing there is if anyway I can add a small view/toolbar to the photo picker view, like the example did, I then can do the rest

Example Looking - With the custom toolbar in the bottom

    - (void)getMediaFromSource:(UIImagePickerControllerSourceType)sourceType{
      //get all available source types
      NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];

      //if source type available and supported media type is not null
      if ([UIImagePickerController isSourceTypeAvailable:sourceType
           && [mediaTypes count] > 0]) {

        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        //picker.mediaTypes = mediaTypes;   //allow videos
        picker.delegate = self;
        picker.sourceType = sourceType; //set source type to the given type

        /** WANT TO ADD A CUSTOM VIEW IN THE PHOTO PICKER VIEW **/

        [self presentViewController:picker animated:YES completion:nil];
      } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing media"
                                                        message:@"Device doesn't support that media type"
                                                       delegate:nil
                                              cancelButtonTitle:@"Drat !"
                                              otherButtonTitles: nil];
        [alert show];
      }
    }

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
      self.lastChosenMediaType = [info objectForKey:UIImagePickerControllerMediaType];  //record media type

      //if media type is image
      if ([lastChosenMediaType isEqual:(NSString *) kUTTypeImage]) {
        UIImage *chosenImage = [info objectForKey:UIImagePickerControllerOriginalImage];    //load image

        //save the image if is from camera shot
        if (imageOrVideoSourceType == UIImagePickerControllerSourceTypeCamera) {
          UIImageWriteToSavedPhotosAlbum (chosenImage, nil, nil , nil);
        }

        [images addObject:chosenImage]; //add to image list
        imageNum++;
      }

      changeImageOrVideo = true;

      if(imageNum >= 5){
          [picker dismissViewControllerAnimated:YES completion:nil];
      }
    }
phil88530
  • 1,499
  • 3
  • 19
  • 27
  • Have a look at the asset library. http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html – iDev Oct 26 '12 at 19:29
  • would you be a little bit more detailed? I am looking at the library but I think I need some hint on how(Never used it before) – phil88530 Oct 26 '12 at 19:42
  • Some tutorials on asset libraries are, http://www.icodeblog.com/2010/07/08/asset-libraries-and-blocks-in-ios-4/ or http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/ You can also check this custom uiimagepicker implementation http://www.icodeblog.com/2011/03/03/update-elcimagepickercontroller/ – iDev Oct 26 '12 at 19:50
  • I don't need a full access to the photolibrary, I can spent few days implement the picker myself, but I still wonder, is there anyway just to get the photo pick view, and customize to add a small view on bottom, or a tiny banner with transparent on top of it? so it's quick and easy – phil88530 Oct 26 '12 at 20:23
  • What was the problem with [picker addSubview:toolbar];?? – iDev Oct 26 '12 at 22:16
  • picker is the UIImagePickerController, how can you add a subview to it?(And I want add a subview to the photo selection view(picker controls camera view, albums view and image picker view) – phil88530 Oct 27 '12 at 15:27

1 Answers1

4

The main reason for using hacks like shifting the UIImagePickerController up and showing selected images underneath was because the asset library alternative would involve the user being asked for location access due to the information about where the photo was taken being available in the image metadata.

In iOS 6 the user is asked if they want to allow the app to access their photos (not location) and you get asked this question for both the asset library approach and the UIImagePickerController approach.

As such I think that hacks like the above are nearing the end of their usefulness. Here is a link to a library providing selection of multiple images using the Assets library there are others.

EarlyRiser
  • 727
  • 3
  • 6
  • I am using this at the moment. but trying to understand how to write my own custom picker. (I want to be able merge the camera view as well, so in the camera view you can switch to photo picking view, and if you take a picture, it then switch back to photo picker view with the image selected – phil88530 Oct 27 '12 at 15:29
  • There isn't some good tutorials about how to use the assets library creating custom pickers, but the example supports ARC and can be modified slightly to fit most purpuoses – phil88530 Oct 31 '12 at 08:39