Latest 2.1.1
Homepage https://github.com/darling0825/DLPhotoPicker
License MIT
Platforms ios 8.0, requires ARC
Dependencies PureLayout, SVProgressHUD, TOCropViewController
Authors

Build Status
codecov.io
[CocoaPods]()
[GitHub watchers]()
GitHub stars
GitHub forks
GitHub issues
GitHub license
Twitter

iOS control that allows picking or displaying photos and videos from user’s photo library.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like DLPhotoPicker in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate DLPhotoPicker into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'DLPhotoPicker'

Then, run the following command:

$ pod install

Screenshot

image
image
image
image
image
image
image
image
image
image
image
image
image
image

Features

  • Support AssetsLibrary(iOS7) and Photos(iOS 8 or later) framework.
  • Support photo display, edit and pick.
  • Suppert save the photo to a album and save to document of app sandbox.

Usage

First import header file: DLPhotoPicker.h

To display all albums and photos.

- (IBAction)clickPhotoDisplayAction:(id)sender 
{
    DLPhotoPickerViewController *picker = [[DLPhotoPickerViewController alloc] init];
    picker.delegate = self;
    picker.pickerType = DLPhotoPickerTypeDisplay;
    picker.showsNumberOfAssets = YES;
    picker.navigationTitle = NSLocalizedString(@"Albums", nil);

    [self presentViewController:picker animated:YES completion:nil];
  }

To pick photo or video from photo library.

- (void)pickAssets:(id)sender
{
    DLPhotoPickerViewController *picker = [[DLPhotoPickerViewController alloc] init];
    picker.delegate = self;
    picker.pickerType = DLPhotoPickerTypePicker;
    picker.navigationTitle = NSLocalizedString(@"Albums", nil);

    [self presentViewController:picker animated:YES completion:nil];
}

The Delegate of DLPhotoPicker

-(void)pickerController:(DLPhotoPickerViewController *)picker didFinishPickingAssets:(NSArray *)assets
{
    [self dismissViewControllerAnimated:YES completion:nil];

    self.assets = [NSArray arrayWithArray:assets];

    // to operation with 'self.assets'
}

- (BOOL)pickerController:(DLPhotoPickerViewController *)picker shouldScrollToBottomForPhotoCollection:(DLPhotoCollection *)assetCollection;
{
    return YES;
}

- (BOOL)pickerController:(DLPhotoPickerViewController *)picker shouldEnableAsset:(DLPhotoAsset *)asset
{
    return YES;
}

- (BOOL)pickerController:(DLPhotoPickerViewController *)picker shouldSelectAsset:(DLPhotoAsset *)asset
{
    NSInteger max = 10;

    if (picker.selectedAssets.count >= max){
        UIAlertController *alert =
        [UIAlertController alertControllerWithTitle:@"Attention"
                                            message:[NSString stringWithFormat:@"Please select not more than %ld assets", (long)max]
                                     preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *action =
        [UIAlertAction actionWithTitle:@"OK"
                                 style:UIAlertActionStyleDefault
                               handler:nil];

        [alert addAction:action];

        [picker presentViewController:alert animated:YES completion:nil];
    }

    // limit selection to max
    return (picker.selectedAssets.count < max);

    return YES;
}

- (void)pickerController:(DLPhotoPickerViewController *)picker didSelectAsset:(DLPhotoAsset *)asset
{
    // didSelectAsset
}

- (BOOL)pickerController:(DLPhotoPickerViewController *)picker shouldDeselectAsset:(DLPhotoAsset *)asset
{
    return YES;
}

- (void)pickerController:(DLPhotoPickerViewController *)picker didDeselectAsset:(DLPhotoAsset *)asset
{
    // didDeselectAsset
}

- (BOOL)pickerController:(DLPhotoPickerViewController *)picker shouldHighlightAsset:(DLPhotoAsset *)asset
{
    return YES;
}

- (void)pickerController:(DLPhotoPickerViewController *)picker didHighlightAsset:(DLPhotoAsset *)asset
{
   //  didHighlightAsset
}

License

DLPhotoPicker is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "DLPhotoPicker",
    "version": "2.1.1",
    "summary": "iOS control that allows picking or displaying photos and videos from user's photo library.",
    "description": "DLPhotoPicker is an iOS controller that allows pickingnor displaying photos and videos from user's photo library.nThe usage and look-and-feel just similar to UIImagePickerController.nIt uses **ARC** and **Photos** frameworks.",
    "homepage": "https://github.com/darling0825/DLPhotoPicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "darling0825": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/darling0825/DLPhotoPicker.git",
        "tag": "2.1.1"
    },
    "public_header_files": "DLPhotoPicker/**/*.h",
    "source_files": "DLPhotoPicker/**/*.{h,m}",
    "resource_bundles": {
        "DLPhotoPicker": [
            "DLPhotoPicker/Resources/*.xcassets",
            "DLPhotoPicker/Resources/Localizations/*.lproj"
        ]
    },
    "ios": {
        "frameworks": "Photos"
    },
    "requires_arc": true,
    "dependencies": {
        "PureLayout": [
            "~> 3.0.0"
        ],
        "SVProgressHUD": [],
        "TOCropViewController": []
    }
}

Pin It on Pinterest

Share This