Skip to content

romfeo/photo-picker-plus-ios

 
 

Repository files navigation

Important

There has been a complete rework of the PhotoPicker component.

If you are using the old legacy code you can find it in the pp-v1-legacy branch. Read the documentation and migrate to the new version of the Photo Picker. It contains the Library and a Sample Project which you can use as a reference.

Native Android Component

The Android component has been moved into its own separate GitHub Repository.

You can find it on the following link along with the sample project: https://github.com/chute/photo-picker-plus-android

PhotoPickerPlus

No external dependancies beyond Chute SDK which you can also find here:

https://github.com/chute/Chute-SDK-v2-iOS

Description

This class allows you to pick a photo from any supported online source such as Facebook, Instagram and Dropbox among others. It also replaces the standard picker in that it allows you to pick photos from the device, take photo with the camera or just to pick the latest photo in your library. It has integrated support for multiple image selection, just as the original Image Picker from Apple.

Screenshots

screen1 screen2 screen3 screen4 screen5 screen6 screen7 screen8 screen9 screen10 screen11 screen12 screen13

Initialization

  • isMultipleSelectionEnabled - BOOL - If YES, picker does multi image selection, if NO, picker does single image selection.
  • delegate NSObject <PhotoPickerPlusDelegate> - The delegate for this component. It should implement two of the following delegate methods, depending on single or multiple selection. * - (void)imagePickerController:(PhotoPickerViewController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info; * - (void)imagePickerController:(PhotoPickerViewController *)picker didFinishPickingArrayOfMediaWithInfo:(NSArray *)info; * - (void)imagePickerControllerDidCancel:(PhotoPickerViewController *)picker;

Implementation

You will need to implement PhotoPickerPlus.h in your .h file. You will also need to put <PhotoPickerViewControllerDelegate>

	- (void)imagePickerControllerDidCancel:(PhotoPickerViewController *)picker{
    	if (self.popoverController) {
        	[self.popoverController dismissPopoverAnimated:YES];
    	}
    	else {
        	[self dismissViewControllerAnimated:YES completion:nil];
    	}
	}
	
    ////////////////////////
    //	  Single Photo	  //
    ////////////////////////
    
    - (void)showPhotoPickerPlus {
    	PhotoPickerViewController *picker = [PhotoPickerViewController new];
    	[picker setDelegate:self];
    	[picker setIsMultipleSelectionEnabled:NO];
    
    	if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        	if (![[self popoverController] isPopoverVisible]) {
            	UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
            	[popover presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
	            self.popoverController = popover;
    	    }
        	else {
            	[[self popoverController] dismissPopoverAnimated:YES];
	        }
    	}
	    else {
    	    [self presentViewController:picker animated:YES completion:nil];
	    }
	}
	
	- (void)imagePickerController:(PhotoPickerViewController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
		//place code for when the user picks photos here and do any
	    //additional work such as removing the picker from the screen
	}
	
	///////////////////////
    //	  Multi Photo    //
    ///////////////////////
    
    - (void)showPhotoPickerPlus {
    	PhotoPickerViewController *picker = [PhotoPickerViewController new];
    	[picker setDelegate:self];
    	[picker setIsMultipleSelectionEnabled:YES];
    	
    	if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        	if (![[self popoverController] isPopoverVisible]) {
            	UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
            	[popover presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
            	self.popoverController = popover;
        	}
        	else {
            	[[self popoverController] dismissPopoverAnimated:YES];
        	}
    	}
    	else {
        	[self presentViewController:picker animated:YES completion:nil];
    	}
	}
	
	- (void)imagePickerController:(PhotoPickerViewController *)picker didFinishPickingArrayOfMediaWithInfo:(NSArray *)info{
		//place code for when the user picks photos here and do any
	    //additional work such as removing the picker from the screen
	}

Tutorials

Adding PhotoPicker+ to an Existing Project

Creating a PhotoPicker+ Sample Project

About

Repo for Photo Picker Plus by Chute

Resources

License

Stars

Watchers

Forks

Packages

No packages published