Skip to content

leverdeterre/MediaPickerManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MediaPickerManager

  • allows to simplify usage of UIImagePickerController,
  • no need to manipulate UIPopoverController / UIActionSheet
  • more code clarity,
  • iPad and iPhone support.

Release note

v0.0.3 : Framework localization + bundle generation v0.0.2 : Refactor

Shared object that

[MediaPickerManager sharedInstance]

Enum to configure the mediaPicker

typedef NS_OPTIONS(NSInteger,  JMMediaType) {
    JMMediaTypeCameraPhoto = 0,
    JMMediaTypeCameraVideo = 1 << 0,
    JMMediaTypeLibraryPhoto = 1 << 1,
    JMMediaTypeLibraryVideo = 1 << 2,
    JMMediaTypeCamera = JMMediaTypeCameraPhoto | JMMediaTypeCameraVideo,
    JMMediaTypeLibrary = JMMediaTypeLibraryPhoto | JMMediaTypeLibraryVideo,
    JMMediaTypePhotos = JMMediaTypeCameraPhoto | JMMediaTypeLibraryPhoto,
    JMMediaTypeVideos = JMMediaTypeCameraVideo | JMMediaTypeLibraryVideo,
    JMMediaTypeAll = JMMediaTypeCamera | JMMediaTypeLibrary,
};

Enum to configure the the presentation of ImagePicker

typedef NS_ENUM(NSInteger,  JMMediaPresentationStyle) {
    JMMediaPresentationStylePresentModal,
    JMMediaPresentationStyleAddSubView,
    JMMediaPresentationStyleCustom
};

Usage ... very simple with a protocol

@protocol JMMediaPickerManagerDelegate <NSObject>
- (void)imagePickerControllerDidFinishPickingMediaWithInfo:(NSDictionary *)info;
@optional
- (void)customPresentImagePicker:(UIViewController *)controller;
- (void)customDismissImagePicker:(UIViewController *)controller;
@end
#import "MediaPickerManager.h"

- (IBAction)photoSelected:(id)sender 
{
    [MediaPickerManager sharedInstance].type = JMMediaTypePhotos;
    [MediaPickerManager sharedInstance].delegate = self;
    [[MediaPickerManager sharedInstance] presentPhotosFrom:sender];
}

#pragma mark JMMediaPickerManagerDelegate

- (void)imagePickerControllerDidFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSLog(@"%s",__FUNCTION__);
    
    NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if ( [mediaType isEqualToString:@"public.movie" ])
    {
        NSLog(@"Picked a movie at URL %@",  [info objectForKey:UIImagePickerControllerMediaURL]);
        NSURL *url =  [info objectForKey:UIImagePickerControllerMediaURL];
        
    }
    else {
        UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
    }
}

About

Shared object that allow to simplify UIImagePickerController

Resources

License

Stars

Watchers

Forks

Packages

No packages published