Latest 1.0.1
Homepage https://github.com/Soul-Beats/SLPhotosPickerController
License MIT
Platforms ios 7.0, requires ARC
Frameworks AssetsLibrary
Authors

SLPhotosPickerController is a photos picker controller (Objective-C & AssetLibrary), which gives you access to pick multiple photos from your Photos application. Its UI and UX is inspired from WeChat and Photos.

Screenshot1Screenshot2Screenshot3

Requirements

  • iOS 7.0+
  • ARC

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

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

pod 'SLPhotosPickerController', `~> 1.0.0`

Then, run the following command:

$ pod install

You should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

Manually

It’s also easy to integrate SLPhotosPickerController into your project. Just add Source directory into your project, and it’s done. Then, you can #import "SLPhotosPickerController" into any files, and use it freely. By the way, I recommend you to rename the directory from Source to SLPhotosPickerController.

Usage

Use SLPhotosPickerController in your project is as easy as a pie. Look at the code in Demo.xcodeproj:

- (IBAction)showPhotosPicker:(id)sender {
    SLPhotosPickerController *photosPicker = [[SLPhotosPickerController alloc] init];
    photosPicker.tintColor = self.view.tintColor;
    photosPicker.maximumNumberOfSelectedPhotos = 9;
    photosPicker.pickerDelegate = self;
    [self presentViewController:photosPicker animated:YES completion:NULL];
}

And also see its header file:

@class SLPhotosPickerController;
@protocol SLPhotosPickerControllerDelegate <NSObject>
- (void)photosPickerControllerDidCancel:(SLPhotosPickerController *)picker;
- (void)photosPickerController:(SLPhotosPickerController *)picker didFinishPickingPhotoAssets:(NSArray *)photoAssets;
@end

@interface SLPhotosPickerController : UINavigationController
@property (nonatomic, weak) id<SLPhotosPickerControllerDelegate> pickerDelegate;
@property (nonatomic, strong) UIColor *tintColor; // Color for selection appearance and done item
// Maximum number of selected photos. If user has selected this number of photos and trying to select one more, an alert will be shown.
@property (nonatomic, assign) NSUInteger maximumNumberOfSelectedPhotos;
@end

Now, I think you can know how to use it. It is partly like UIImagePickerController, but it is simpler than that. Before presenting it, you can set the tintColor, which controls the color of selection appearance and done item, maximumNumberOfSelectedPhotos, which controls the maximum number of selected photos like what its name means.

Because of SLPhotosPickerController class is subclass of UINavigationController, you can use apis of UINavigationController to do anything you want, such as navigationBar property, so you can change the background Color and title style of navigation bar. But, don’t set the delegate property, because in the implementation file, I have set itself as the delegate for transitioning.

Use pickerDelegate to get the selected photos which is of type ALAsset, or get a chance to do something you want when cancelled.

In the End

SLPhotosPickerController is created for a simple aim: Picking multiple photos from your Photos.app. So I make it clean and simple with a few apis. Its code is not hard, so I think everyone can read it and adjust it for his own requirements, welcome it. Welcome any pull requests and any advice as well.

MIT License

The MIT License (MIT)

Copyright (c) 2015 Soul

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Latest podspec

{
    "name": "SLPhotosPickerController",
    "version": "1.0.1",
    "summary": "A Photos Picker Controller (Objective-C & AssetsLibrary).",
    "description": "A Photos Picker Controller (Objective-C & AssetsLibrary) Inspired from WeChat and Photos.",
    "homepage": "https://github.com/Soul-Beats/SLPhotosPickerController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Soul-Beats": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Soul-Beats/SLPhotosPickerController.git",
        "tag": "v1.0.1"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source_files": "Source/**/*.{h,m}",
    "resources": [
        "Source/Helper/*.png",
        "Source/**/*.xib"
    ],
    "frameworks": "AssetsLibrary",
    "requires_arc": true
}

Pin It on Pinterest

Share This