Skip to content

JDGan/JDGImagePicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JDGImagePicker

Version License Platform

Example

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

Requirements

iOS : 11.0以上,仅支持iPhone

Installation

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

# 使用全部完整功能
pod 'JDGImagePicker'

# 仅使用图片选择器的功能
pod 'JDGImagePicker/ImagePicker'

# 仅使用预览的功能(开发中)
pod 'JDGImagePicker/ImagePreviewer'

Usage

首先在InfoPlist中添加权限描述:

  1. NSCameraUsageDescription -> Privacy - Photo Library Usage Description
  2. NSPhotoLibraryUsageDescription -> Privacy - Camera Usage Description

然后按下面的逻辑使用代码

//...
#import <JDGImagePicker/JDGImagePicker.h>
//...
@interface XXXViewController() <JDGImagePickerDelegate>
//...
@implementation XXXViewController
//...
- (void)actionToShowPicker {
//...
    JDGImagePicker *picker = JDGImagePicker.shared;
    picker.delegate = self;
    JDGImagePickerConfiguration *config = JDGImagePickerConfiguration.shared;
    config.imageSize = UIScreen.mainScreen.bounds.size;// or any other sizes
    config.doneButtonTitle = @"完成";
    config.cancelButtonTitle = @"取消";
    [picker presentFromViewController:self animated:YES completion:^{
        // complete animation
    }];
}
#pragma mark - JDGImagePickerDelegate
- (void)imagePicker:(JDGImagePicker *)imagePicker didFinishWithResultSelection:(JDGImageStack *)resultSelection {
    JDGImagePickerPhoto *photo = resultSelection.selectedPhotos.firstObject;
    [photo getOriginImageInMainQueueCompletion:^(UIImage * _Nullable image, NSError * _Nullable error) {
        // origin image here
    }];
    
    [photo getThumbnailImageInMainQueueCompletion:^(UIImage * _Nullable image, NSError * _Nullable error) {
        // thumbnail image here, this run much faster
    }];
    // destroy Shared instance if you need
    [JDGImagePicker destroyShared];
    [JDGImagePickerConfiguration destroyShared];
}

- (void)imagePickerDidCancel:(JDGImagePicker *)imagePicker {
    // destroy Shared instance if you need
    [JDGImagePicker destroyShared];
    [JDGImagePickerConfiguration destroyShared];
}
@end

Author

JDGan, jessiegan1987@163.com

License

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

About

简单粗暴的图片选择器,整合相机

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors