This class provides the capabilities for selecting an image from the photo library or camera, or submitting one for editing in a circular mask. The selected and edited image would typically be used for a profile displayed in a circle. With this class an application can provide identical profile selection features found in the contacts app.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Import the class header.
#import "MMSProfileImagePicker.h"
Create a the profile picker object. The application's view controller implements the MMSProfileImagePickerDelegate interface. The interface's method is where profile picker passes the selected and edited image. Before calling one of the profile picker's methods, the application sets its delegate property.
- (IBAction)pickFromCamera {
profilePicker = [[MMSProfileImagePicker alloc] init];
profilePicker.delegate = self;
[profilePicker selectFromCamera:self];
}
There are three public methods for selecting and editing a profile image. For editing an existing image call...
-(void)presentEditScreen:(UIViewController* _Nonnull)vc withImage:(UIImage* _Nonnull)image;
For editing an image selected from the photo library call...
-(void)selectFromPhotoLibrary:(UIViewController* _Nonnull)vc;
For editing an image selected from the camera call...
-(void)selectFromCamera:(UIViewController* _Nonnull)vc;
To receive the selected and edited image implement the delegate method...
-(void)mmsImagePickerController:(MMSProfileImagePicker* _Nonnull)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString*, id>*_Nonnull)info;
The dictionary parameter supports all the editing information keys defined in editing information keys found in the iOS developer documentation.
If the user cancels the selection, the application receives notificaton on the delegate method...
-(void)mmsImagePickerControllerDidCancel:(MMSProfileImagePicker * _Nonnull)picker;
MMSProfileImagePicker requires iOS 7.2 or later.
MMSProfileImagePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MMSProfileImagePicker"
An article describing the implementation of the class: A Class for Selecting a Profile Image.
A related article describing the cropping category: A View Class for Cropping Images.
William Miller, [email protected]
This project is is available under the MIT license. See the LICENSE file for more info. Add attibution by linking to the project page is appreciated.