Giter Site home page Giter Site logo

liphotoskitmanager's Introduction

LIPhotosKitManager

BuildVersionLicensePlatform

Easier to use PhotosKit

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Xcode 6
  • iOS 8.0 +

Installation

LIPhotosKitManager is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "LIPhotosKitManager"

How to use

Importing Headers then create property and initialization

#import <LIPhotosKitManager.h> //---------------------------------------1

@interface ViewController ()<LIPhotosKitManagerDelegate>
@property (nonatomic, strong) LIPhotosKitManager *manager; //-----------2
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    
    //------------------------------------------------------------------3
    self.manager = [[LIPhotosKitManager alloc] init];
    self.manager.delagate = self;
}

- (void)managerDidReceivePhotoLibraryChangeNotification
{    
	// delegate method
    // update your datasource and refresh ui
}
@end

Get Albums

You can use allSystemAlbums or allUserCustomAlbums methods to get albums in your device. These methods return a array contain LIAlbum objects.

NSArray *systemAlbums = [self.manager allSystemAlbums];
NSArray *customAlbums = [self.manager allUserCustomAlbums];

Get Photos

Before obtaining Photos, you must get the LIID object. There are two ways to get that object. One is read from LIAlbum object, another is use the allPhotosIDSortByCreateDateAscending:

NSArray *imageIDs = [self.manager allPhotosIDSortByCreateDateAscending:YES];

Everything is ready ,use the following methods to get the photos you want:

  • requestThumbnailImageForID:size:contentMode:target:resultHandler:
  • requestOriginalImageForID:target:resultHandler:
  • requestOriginalImageDataForID:target:resultHandler:

Esample

LIID *idObj = self.imageIDs[index];
UIImageView *imageView = self.imageView;
[self.manager requestThumbnailImageForID:idObj size:CGSizeMake(100, 100) contentMode:0 target:imageView resultHandler:^(UIImage *result, id target, NSDictionary *info) {
	UIImageView *imageView = target;
	imageView.image = result;
}];

Author

Ruwei Li, [email protected]

License

LIPhotosKitManager is available under the MIT license. See the LICENSE file for more info.

liphotoskitmanager's People

Contributors

kostassite avatar liruwei avatar

Stargazers

Richard_Liang avatar Mason avatar Cătălin Stan avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

kimbin kostassite

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.