Skip to content

A UIImagePickerController drop-in replacement that works in all orientations.

License

Notifications You must be signed in to change notification settings

postmechanical/AssetPicker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AssetPicker

DIYAssetPicker is a drop-in replacement for UIImagePickerController. It works in all screen orientations and it packs a convenient thumbnail with the output dictionary.

Basic Use

DIYAssetPickerController *picker = [[DIYAssetPickerController alloc] init];
picker.delegate = self;
[self presentModalViewController:picker animated:true];
[picker release];

Protocol

Methods:

@protocol DIYAssetPickerControllerDelegate <NSObject>
@required
// These are equivalent to the UIImagePickerController delegate methods
- (void)pickerDidCancel:(DIYAssetPickerController *)picker;
- (void)pickerDidFinishPickingWithInfo:(NSDictionary *)info;
@optional
// The picker takes a few hundred milliseconds to load libraries with hundreds of items; use this if you want to do something cute during loading
- (void)pickerDidFinishLoading;
// Hook this up to shouldAutorotateToInterfaceOrientation in the delegate if you want the picker to autorotate
- (BOOL)shouldPickerAutorotate:(UIInterfaceOrientation)toInterfaceOrientation;
@end

Output dictionary keys:

// Same as Apple's
NSString *const UIImagePickerControllerMediaType;
NSString *const UIImagePickerControllerOriginalImage;
NSString *const UIImagePickerControllerReferenceURL;
NSString *const UIImagePickerControllerMediaURL;

// NEW STUFF
NSString *const DIYAssetPickerThumbnail; // UIImage of the asset's thumbnail

Check out the UIImagePickerControllerDelegate Protocol Reference

Properties

@property (assign) id<DIYAssetPickerControllerDelegate> delegate;
// Set assetType to show only photos, only videos, or both. Defaults to both
@property (nonatomic, assign) DIYAssetPickerControllerAssetType assetType;

ARC

DIYAssetPicker as of v0.3.0 is built using ARC. If you are including DIYAssetPicker in a project that does not use Automatic Reference Counting (ARC), you will need to set the -fobjc-arc compiler flag on all of the DIYAssetPicker source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. Now select all DIYAssetPicker source files, press Enter, insert -fobjc-arc and then "Done" to enable ARC for DIYAssetPicker.

CAVEATS:

Credits

Brandon Coston did some smart stuff in PhotoPickerPlus to create a gridded table view. I totally copped some ideas and code from that project. Andrew Sliwinski reviewed the code and pushed me to make it better.

About

A UIImagePickerController drop-in replacement that works in all orientations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 97.7%
  • Ruby 2.3%