Select Multiple Images (Uiimagepickercontroller or Photos.App Share Ui)

How to select Multiple images from UIImagePickerController

You can't use UIImagePickerController, but you can use a custom image picker. I think ELCImagePickerController is the best option, but here are some other libraries you could use:

Objective-C

1. ELCImagePickerController

2. WSAssetPickerController

3. QBImagePickerController

4. ZCImagePickerController

5. CTAssetsPickerController

6. AGImagePickerController

7. UzysAssetsPickerController

8. MWPhotoBrowser

9. TSAssetsPickerController

10. CustomImagePicker

11. InstagramPhotoPicker

12. GMImagePicker

13. DLFPhotosPicker

14. CombinationPickerController

15. AssetPicker

16. BSImagePicker

17. SNImagePicker

18. DoImagePickerController

19. grabKit

20. IQMediaPickerController

21. HySideScrollingImagePicker

22. MultiImageSelector

23. TTImagePicker

24. SelectImages

25. ImageSelectAndSave

26. imagepicker-multi-select

27. MultiSelectImagePickerController

28. YangMingShan(Yahoo like image selector)

29. DBAttachmentPickerController

30. BRImagePicker

31. GLAssetGridViewController

32. CreolePhotoSelection

Swift

1. LimPicker (Similar to WhatsApp's image picker)

2. RMImagePicker

3. DKImagePickerController

4. BSImagePicker

5. Fusuma(Instagram like image selector)

6. YangMingShan(Yahoo like image selector)

7. NohanaImagePicker

8. ImagePicker

9. OpalImagePicker

10. TLPhotoPicker

11. AssetsPickerViewController

12. Alerts-and-pickers/Telegram Picker

Thanx to @androidbloke,

I have added some library that I know for multiple image picker in swift.

Will update list as I find new ones.

Thank You.

How to display two images on two UIImageViews one View Controller, UIImagePickerController's?

What you observe is that when the user taps on any of the image views (wallpaperPhoto or profilePhoto), the UIImagePickerController always uses self as its delegate. Then, when the user picks an image, the delegate cannot distinguish any more which image view originally was tapped.

You could simply add a weak optional variable indicating the "active" tapped image view, and then set only it's image. Also, you can reduce the tap handler to a single function with a sender argument, which is the image view the user tapped on, and set the activeImageViewto this.

extension SettingProfileViewController:UIImagePickerControllerDelegate, UINavigationControllerDelegate {
weak var activeImageView:UIImageView? = nil

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
activeImageView.image = image
}
dismiss(animated: true, completion: nil)
}


override func viewDidLoad() {
super.viewDidLoad()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(SettingProfileViewController.handleSelect(_:))
profilePhoto.addGestureRecognizer(tapGesture)
profilePhoto.isUserInteractionEnabled = true

let wallTapGesture = UITapGestureRecognizer(target: self, action: #selector(SettingProfileViewController.handleSelect(_:)))
wallpaperPhoto.addGestureRecognizer(wallTapGesture)
wallpaperPhoto.isUserInteractionEnabled = true
}

@objc func handleSelect(sender:UIGestureRecognizer) {
guard let sendingImageView = sender.view as? UIImageView else {
print("Ooops, received this gesture not from an ImageView")
return
}
activeImageView = sendingImageView
let pickerController = UIImagePickerController() //открывает галерею
pickerController.delegate = self
present(pickerController, animated: true, completion: nil)
}

// ...

Select Multiple Images from Photo Library

Ok, I have this figured out. The problem with Assets Library is that it gives you all the GEO data of the image. What that means for your users using your app is that they will get a prompt saying that your app is trying to access their location. Infact all you are trying to do is let them choose multiple images from their photo-album. Most users will be turned off thinking its a piracy issue. The best approach is to use apples api of imagePickerController. I know it lets you choose one pic at a time but if you add the following code, it will let you choose multiple pictures.

The way I am doing is let the users keep selecting pictures they want, keep saving those files in the app documents directory, till they hit the done button. See here my sample code and hopefully it will save you the pain of going through Assets Library

-(IBAction)selectExitingPicture
{
//Specially for fing iPAD
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];

popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popoverController presentPopoverFromRect:CGRectMake(0.0, 0.0, 400.0, 300.0)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}

//Done button on top
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
//NSLog(@"Inside navigationController ...");


if (!doneButton)
{
doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleDone
target:self action:@selector(saveImagesDone:)];
}

viewController.navigationItem.rightBarButtonItem = doneButton;
}

- (IBAction)saveImagesDone:(id)sender
{
//NSLog(@"saveImagesDone ...");

[popoverController dismissPopoverAnimated:YES];
}


-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{


//DONT DISMISS
//[picker dismissModalViewControllerAnimated:YES];
//[popoverController dismissPopoverAnimated:YES];

IMAGE_COUNTER = IMAGE_COUNTER + 1;

imageView.image = image;

// Get the data for the image
NSData* imageData = UIImageJPEGRepresentation(image, 1.0);


// Give a name to the file
NSString* incrementedImgStr = [NSString stringWithFormat: @"UserCustomPotraitPic%d.jpg", IMAGE_COUNTER];


NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];

// Now we get the full path to the file
NSString* fullPathToFile2 = [documentsDirectory stringByAppendingPathComponent:incrementedImgStr];

// and then we write it out
[imageData writeToFile:fullPathToFile2 atomically:NO];

}

//Now use this code to get to user selected pictures. Call it from wherever you want in your code

 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES);
NSString* documentsPath = [paths objectAtIndex:0];
NSString* dataFile = [documentsPath stringByAppendingPathComponent:@"UserCustomPotraitPic1.jpg"];

NSData *potraitImgData = [NSData dataWithContentsOfFile:dataFile];
backgroundImagePotrait = [UIImage imageWithData:potraitImgData];

Select multiple photos from camera roll in iPhone

ELCImagePicker will accomplish this exactly.



Related Topics



Leave a reply



Submit