├── CDZImagePickerDemo ├── Assets.xcassets │ ├── Contents.json │ ├── clock-icon.imageset │ │ ├── clock-icon.png │ │ └── Contents.json │ ├── phone-icon.imageset │ │ ├── phone-icon.png │ │ └── Contents.json │ ├── camera-icon.imageset │ │ ├── camera-icon.png │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── Default-568h@2x.png ├── ViewController.h ├── AppDelegate.h ├── main.m ├── CDZImagePicker │ ├── CDZImagePickerPhotosView │ │ ├── CDZImagePickerPhotosCell.h │ │ ├── CDZImagePickerPhotosDataSource.h │ │ ├── CDZImagePickerPhotosDataSource.m │ │ └── CDZImagePickerPhotosCell.m │ ├── CDZImagePickerActionsView │ │ ├── CDZImagePickerActionsCell.h │ │ ├── CDZImagePickerActionsDataSource.h │ │ ├── CDZImagePickerActionsItem.m │ │ ├── CDZImagePickerActionsItem.h │ │ ├── CDZImagePickerActionsDataSource.m │ │ └── CDZImagePickerActionsCell.m │ ├── CDZImagePickerViewController.h │ ├── CDZImagePickerConstant.h │ └── CDZImagePickerViewController.m ├── Info.plist ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── ViewController.m └── AppDelegate.m ├── CDZImagePickerDemo.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj ├── CDZImagePicker ├── CDZImagePickerPhotosCell.h ├── CDZImagePickerActionsCell.h ├── CDZImagePickerActionsDataSource.h ├── CDZImagePickerPhotosDataSource.h ├── CDZImagePickerViewController.h ├── CDZImagePickerActionsItem.m ├── CDZImagePickerActionsItem.h ├── CDZImagePickerPhotosDataSource.m ├── CDZImagePickerConstant.h ├── CDZImagePickerActionsDataSource.m ├── CDZImagePickerActionsCell.m ├── CDZImagePickerPhotosCell.m └── CDZImagePickerViewController.m ├── CDZImagePicker.podspec ├── LICENSE └── README.md /CDZImagePickerDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CDZImagePickerDemo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nemocdz/CDZImagePicker/HEAD/CDZImagePickerDemo/Default-568h@2x.png -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/clock-icon.imageset/clock-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nemocdz/CDZImagePicker/HEAD/CDZImagePickerDemo/Assets.xcassets/clock-icon.imageset/clock-icon.png -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/phone-icon.imageset/phone-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nemocdz/CDZImagePicker/HEAD/CDZImagePickerDemo/Assets.xcassets/phone-icon.imageset/phone-icon.png -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/camera-icon.imageset/camera-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nemocdz/CDZImagePicker/HEAD/CDZImagePickerDemo/Assets.xcassets/camera-icon.imageset/camera-icon.png -------------------------------------------------------------------------------- /CDZImagePickerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerPhotosCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePIckerPhotosCell.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | @class PHAsset; 11 | 12 | @interface CDZImagePickerPhotosCell : UICollectionViewCell 13 | 14 | @property (nonatomic,strong) PHAsset *item; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerActionsCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsCell.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CDZImagePickerActionsItem; 11 | 12 | @interface CDZImagePickerActionsCell : UITableViewCell 13 | 14 | @property (nonatomic,strong) CDZImagePickerActionsItem *item; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerPhotosView/CDZImagePickerPhotosCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePIckerPhotosCell.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | @class PHAsset; 11 | 12 | @interface CDZImagePickerPhotosCell : UICollectionViewCell 13 | 14 | @property (nonatomic,strong) PHAsset *item; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/camera-icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "camera-icon.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/clock-icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "clock-icon.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/phone-icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "phone-icon.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerActionsDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsDataSource.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CDZImagePickerActionsDataSource : NSObject 13 | 14 | @property (nonatomic, strong) NSMutableArray *itemArray; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerPhotosDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerPhotosDataSource.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CDZImagePickerPhotosDataSource : NSObject 13 | 14 | @property (nonatomic, strong) NSArray *itemsArray; 15 | 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerActionsView/CDZImagePickerActionsCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsCell.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CDZImagePickerActionsItem; 11 | 12 | @interface CDZImagePickerActionsCell : UITableViewCell 13 | 14 | @property (nonatomic,strong) CDZImagePickerActionsItem *item; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerActionsView/CDZImagePickerActionsDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsDataSource.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CDZImagePickerActionsDataSource : NSObject 13 | 14 | @property (nonatomic, strong) NSMutableArray *itemArray; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerPhotosView/CDZImagePickerPhotosDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerPhotosDataSource.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CDZImagePickerPhotosDataSource : NSObject 13 | 14 | @property (nonatomic, strong) NSArray *itemsArray; 15 | 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerView.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CDZImagePickerConstant.h" 11 | 12 | @interface CDZImagePickerViewController : UIViewController 13 | 14 | @property (nonatomic ,strong) NSMutableArray *actionArray; 15 | 16 | - (void)openPickerInController:(UIViewController *)controller withImageBlock:(CDZImageResultBlock)imageBlock; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CDZImagePicker.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CDZImagePicker" 3 | s.version = "1.0.0" 4 | s.summary = "A beatiful Imagepickercontroller easy to use" 5 | s.homepage = "https://github.com/Nemocdz/CDZImagePicker" 6 | s.license = "MIT" 7 | s.authors = { 'Nemocdz' => 'nemocdz@gmail.com'} 8 | s.platform = :ios, "8.0" 9 | s.source = { :git => "https://github.com/Nemocdz/CDZImagePicker.git", :tag => s.version } 10 | s.source_files = 'CDZImagePicker', 'CDZImagePicker/**/*.{h,m}' 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerView.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CDZImagePickerConstant.h" 11 | 12 | @interface CDZImagePickerViewController : UIViewController 13 | 14 | @property (nonatomic ,strong) NSMutableArray *actionArray; 15 | 16 | - (void)openPickerInController:(UIViewController *)controller withImageBlock:(CDZImageResultBlock)imageBlock; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerActionsItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsItem.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerActionsItem.h" 10 | 11 | @implementation CDZImagePickerActionsItem 12 | 13 | - (instancetype)initWithTitle:(NSString *)titele withActionType:(CDZImagePickerActionType)type withImage:(UIImage *)image{ 14 | self = [super init]; 15 | if (self) { 16 | _actionTitle = titele; 17 | _actionType = type; 18 | _actionImage = image; 19 | } 20 | return self; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerActionsView/CDZImagePickerActionsItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsItem.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerActionsItem.h" 10 | 11 | @implementation CDZImagePickerActionsItem 12 | 13 | - (instancetype)initWithTitle:(NSString *)titele withActionType:(CDZImagePickerActionType)type withImage:(UIImage *)image{ 14 | self = [super init]; 15 | if (self) { 16 | _actionTitle = titele; 17 | _actionType = type; 18 | _actionImage = image; 19 | } 20 | return self; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerActionsItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsItem.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "CDZImagePickerConstant.h" 12 | 13 | @interface CDZImagePickerActionsItem : NSObject 14 | 15 | @property(nonatomic, copy) NSString *actionTitle; 16 | @property(nonatomic, strong) UIImage *actionImage; 17 | @property(nonatomic, assign) CDZImagePickerActionType actionType; 18 | 19 | - (instancetype)initWithTitle:(NSString *)titele withActionType:(CDZImagePickerActionType)type withImage:(UIImage *)image; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerActionsView/CDZImagePickerActionsItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsItem.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "CDZImagePickerConstant.h" 12 | 13 | @interface CDZImagePickerActionsItem : NSObject 14 | 15 | @property(nonatomic, copy) NSString *actionTitle; 16 | @property(nonatomic, strong) UIImage *actionImage; 17 | @property(nonatomic, assign) CDZImagePickerActionType actionType; 18 | 19 | - (instancetype)initWithTitle:(NSString *)titele withActionType:(CDZImagePickerActionType)type withImage:(UIImage *)image; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerPhotosDataSource.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerPhotosDataSource.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerPhotosDataSource.h" 10 | #import "CDZImagePIckerPhotosCell.h" 11 | 12 | @implementation CDZImagePickerPhotosDataSource 13 | 14 | #pragma mark - collectionViewDataSourceRequried 15 | 16 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 17 | return self.itemsArray.count; 18 | } 19 | 20 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 21 | CDZImagePickerPhotosCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([CDZImagePickerPhotosCell class]) forIndexPath:indexPath]; 22 | cell.item = self.itemsArray[indexPath.row]; 23 | return cell; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerPhotosView/CDZImagePickerPhotosDataSource.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerPhotosDataSource.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerPhotosDataSource.h" 10 | #import "CDZImagePIckerPhotosCell.h" 11 | 12 | @implementation CDZImagePickerPhotosDataSource 13 | 14 | #pragma mark - collectionViewDataSourceRequried 15 | 16 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 17 | return self.itemsArray.count; 18 | } 19 | 20 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 21 | CDZImagePickerPhotosCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([CDZImagePickerPhotosCell class]) forIndexPath:indexPath]; 22 | cell.item = self.itemsArray[indexPath.row]; 23 | return cell; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | CDZImagePicker is available under the MIT license. 2 | 3 | Copyright © 2016 Nemocdz. 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerConstant.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerConstant.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | #import 9 | #import 10 | 11 | @class PHAsset; 12 | 13 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 14 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 15 | #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue] 16 | #define BACKGROUND_BLACK_COLOR [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7] 17 | 18 | static const float actionsViewCellHeight = 54.0f; 19 | static const float photosViewHeight = 165.0f; 20 | static const float photosViewInset = 5.0f; 21 | 22 | 23 | typedef NS_ENUM(NSInteger, CDZImagePickerActionType) { 24 | CDZImagePickerCameraAction, 25 | CDZImagePickerLibraryAction, 26 | CDZImagePickerRecentAction, 27 | CDZImagePickerCloseAction 28 | }; 29 | 30 | 31 | typedef void (^CDZImageResultBlock) (UIImage *image); 32 | 33 | @interface CDZImagePickerConstant : NSObject 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerActionsDataSource.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsDataSource.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerActionsDataSource.h" 10 | #import "CDZImagePickerActionsCell.h" 11 | 12 | @implementation CDZImagePickerActionsDataSource 13 | 14 | #pragma mark - tableViewDataSourceRequried 15 | 16 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 17 | return self.itemArray.count; 18 | } 19 | 20 | 21 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 22 | CDZImagePickerActionsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([CDZImagePickerActionsCell class])]; 23 | if (!cell) { 24 | cell = [[CDZImagePickerActionsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([CDZImagePickerActionsCell class])]; 25 | } 26 | cell.item = self.itemArray[indexPath.row]; 27 | return cell; 28 | } 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerConstant.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerConstant.h 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | #import 9 | #import 10 | 11 | @class PHAsset; 12 | 13 | #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) 14 | #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) 15 | #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue] 16 | #define BACKGROUND_BLACK_COLOR [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7] 17 | 18 | static const float actionsViewCellHeight = 54.0f; 19 | static const float photosViewHeight = 165.0f; 20 | static const float photosViewInset = 5.0f; 21 | 22 | 23 | typedef NS_ENUM(NSInteger, CDZImagePickerActionType) { 24 | CDZImagePickerCameraAction, 25 | CDZImagePickerLibraryAction, 26 | CDZImagePickerRecentAction, 27 | CDZImagePickerCloseAction 28 | }; 29 | 30 | 31 | typedef void (^CDZImageResultBlock) (UIImage *image); 32 | 33 | @interface CDZImagePickerConstant : NSObject 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerActionsView/CDZImagePickerActionsDataSource.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsDataSource.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerActionsDataSource.h" 10 | #import "CDZImagePickerActionsCell.h" 11 | 12 | @implementation CDZImagePickerActionsDataSource 13 | 14 | #pragma mark - tableViewDataSourceRequried 15 | 16 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 17 | return self.itemArray.count; 18 | } 19 | 20 | 21 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 22 | CDZImagePickerActionsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([CDZImagePickerActionsCell class])]; 23 | if (!cell) { 24 | cell = [[CDZImagePickerActionsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([CDZImagePickerActionsCell class])]; 25 | } 26 | cell.item = self.itemArray[indexPath.row]; 27 | return cell; 28 | } 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerActionsCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsCell.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerActionsCell.h" 10 | #import "CDZImagePickerActionsItem.h" 11 | 12 | @implementation CDZImagePickerActionsCell 13 | 14 | - (void)layoutSubviews{ 15 | [super layoutSubviews]; 16 | self.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色 17 | self.imageView.frame = CGRectMake(20, 15, 22, 22); 18 | self.imageView.contentMode = UIViewContentModeScaleAspectFit; 19 | self.textLabel.font = [UIFont systemFontOfSize:16.0f]; 20 | self.textLabel.textColor = [UIColor colorWithRed:0.30 green:0.30 blue:0.30 alpha:1.00]; 21 | if (self.imageView.image){ 22 | self.textLabel.frame = CGRectMake(60, 2, 200, 48); 23 | self.textLabel.textAlignment = NSTextAlignmentLeft; 24 | } 25 | else{ 26 | self.textLabel.textAlignment = NSTextAlignmentCenter; 27 | } 28 | } 29 | 30 | 31 | - (void)setItem:(CDZImagePickerActionsItem *)item{ 32 | self.textLabel.text = item.actionTitle; 33 | self.imageView.image = item.actionImage; 34 | } 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerActionsView/CDZImagePickerActionsCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerActionsCell.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/24. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerActionsCell.h" 10 | #import "CDZImagePickerActionsItem.h" 11 | 12 | @implementation CDZImagePickerActionsCell 13 | 14 | - (void)layoutSubviews{ 15 | [super layoutSubviews]; 16 | self.selectionStyle = UITableViewCellSelectionStyleNone;//点击不变色 17 | self.imageView.frame = CGRectMake(20, 15, 22, 22); 18 | self.imageView.contentMode = UIViewContentModeScaleAspectFit; 19 | self.textLabel.font = [UIFont systemFontOfSize:16.0f]; 20 | self.textLabel.textColor = [UIColor colorWithRed:0.30 green:0.30 blue:0.30 alpha:1.00]; 21 | if (self.imageView.image){ 22 | self.textLabel.frame = CGRectMake(60, 2, 200, 48); 23 | self.textLabel.textAlignment = NSTextAlignmentLeft; 24 | } 25 | else{ 26 | self.textLabel.textAlignment = NSTextAlignmentCenter; 27 | } 28 | } 29 | 30 | 31 | - (void)setItem:(CDZImagePickerActionsItem *)item{ 32 | self.textLabel.text = item.actionTitle; 33 | self.imageView.image = item.actionImage; 34 | } 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSCameraUsageDescription 6 | 需要访问相机 7 | NSPhotoLibraryUsageDescription 8 | 需要访问图库 9 | CFBundleDevelopmentRegion 10 | zh_CN 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerPhotosCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePIckerPhotosCell.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerPhotosCell.h" 10 | #import 11 | 12 | @interface CDZImagePickerPhotosCell() 13 | 14 | @property (nonatomic ,strong) UIImageView *photoImageView; 15 | 16 | @end 17 | 18 | @implementation CDZImagePickerPhotosCell 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame{ 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | [self.contentView addSubview:self.photoImageView]; 24 | } 25 | return self; 26 | } 27 | 28 | - (void)layoutSubviews{ 29 | [super layoutSubviews]; 30 | self.photoImageView.frame = self.contentView.bounds; 31 | } 32 | 33 | - (void)setItem:(PHAsset *)item{ 34 | PHImageRequestOptions *options = [[PHImageRequestOptions alloc]init]; 35 | options.resizeMode = PHImageRequestOptionsResizeModeFast; 36 | [[PHImageManager defaultManager]requestImageForAsset:item targetSize:[UIScreen mainScreen].bounds.size contentMode:PHImageContentModeDefault options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 37 | self.photoImageView.image = result; 38 | }]; 39 | } 40 | 41 | - (UIImageView *)photoImageView{ 42 | if (!_photoImageView) { 43 | _photoImageView = [[UIImageView alloc]initWithFrame:self.contentView.bounds]; 44 | _photoImageView.contentMode = UIViewContentModeScaleAspectFill; 45 | } 46 | return _photoImageView; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerPhotosView/CDZImagePickerPhotosCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePIckerPhotosCell.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/25. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "CDZImagePickerPhotosCell.h" 10 | #import 11 | 12 | @interface CDZImagePickerPhotosCell() 13 | 14 | @property (nonatomic ,strong) UIImageView *photoImageView; 15 | 16 | @end 17 | 18 | @implementation CDZImagePickerPhotosCell 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame{ 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | [self.contentView addSubview:self.photoImageView]; 24 | } 25 | return self; 26 | } 27 | 28 | - (void)layoutSubviews{ 29 | [super layoutSubviews]; 30 | self.photoImageView.frame = self.contentView.bounds; 31 | } 32 | 33 | - (void)setItem:(PHAsset *)item{ 34 | PHImageRequestOptions *options = [[PHImageRequestOptions alloc]init]; 35 | options.resizeMode = PHImageRequestOptionsResizeModeFast; 36 | [[PHImageManager defaultManager]requestImageForAsset:item targetSize:[UIScreen mainScreen].bounds.size contentMode:PHImageContentModeDefault options:options resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 37 | self.photoImageView.image = result; 38 | }]; 39 | } 40 | 41 | - (UIImageView *)photoImageView{ 42 | if (!_photoImageView) { 43 | _photoImageView = [[UIImageView alloc]initWithFrame:self.contentView.bounds]; 44 | _photoImageView.contentMode = UIViewContentModeScaleAspectFill; 45 | } 46 | return _photoImageView; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "CDZImagePickerViewController.h" 11 | #import "CDZImagePickerActionsItem.h" 12 | 13 | 14 | @interface ViewController () 15 | - (IBAction)openPicker:(UIButton *)sender; 16 | @property (strong, nonatomic) IBOutlet UIImageView *imageView; 17 | @property (strong, nonatomic) UIView *backgroundView; 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | } 25 | 26 | - (IBAction)openPicker:(UIButton *)sender { 27 | [self.view addSubview:self.backgroundView]; 28 | CDZImagePickerViewController *imagePickerController = [[CDZImagePickerViewController alloc]init]; 29 | imagePickerController.actionArray = [NSMutableArray arrayWithObjects: 30 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"打开设备上的图片" withActionType:CDZImagePickerLibraryAction withImage:[UIImage imageNamed:@"phone-icon.png"]], 31 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"相机" withActionType:CDZImagePickerCameraAction withImage:[UIImage imageNamed:@"camera-icon.png"]], 32 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"打开最新图片" withActionType:CDZImagePickerRecentAction withImage:[UIImage imageNamed:@"clock-icon.png"]], 33 | nil]; 34 | [imagePickerController openPickerInController:self withImageBlock:^(UIImage *image) { 35 | if (image) { //检查是否有照片 36 | self.imageView.image = image; 37 | } 38 | [self.backgroundView removeFromSuperview]; 39 | }]; 40 | } 41 | 42 | - (UIView *)backgroundView{ 43 | if (!_backgroundView) { 44 | _backgroundView = [[UIView alloc]initWithFrame:self.view.bounds]; 45 | _backgroundView.backgroundColor = BACKGROUND_BLACK_COLOR; 46 | } 47 | return _backgroundView; 48 | } 49 | @end 50 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CDZImagePicker 2 | 3 | This is a ImagePickerController with buttons of action and collection of photos. 4 | 5 | And the button can add beautiful icon like Snapseed used. 6 | 7 | ## Demo Preview 8 | 9 | ![ImagePickerDemo2](http://ww3.sinaimg.cn/large/006y8mN6gw1fai80p1okwg30ku1124oj.gif) 10 | 11 | ## Changelog 12 | 13 | - Add Permisson Check 14 | - CollectionView Realtime Refresh 15 | 16 | ## Installation 17 | 18 | ### Manual 19 | 20 | Add "CDZImagePicker" files to your project 21 | 22 | ### CocoaPods 23 | 24 | Add ``pod 'CDZImagePicker'`` in your Podfile 25 | 26 | ## Usage 27 | 28 | - Use default style 29 | 30 | ```objective-c 31 | #import "CDZImagePickerViewController.h" 32 | ``` 33 | 34 | ```objective-c 35 | CDZImagePickerViewController *imagePickerController = [[CDZImagePickerViewController alloc]init]; 36 | [imagePickerController openPickerInController:self withImageBlock:^(UIImage *image) { 37 | if (image) { //if image has changed 38 | self.imageView.image = image;//your code 39 | } 40 | [self.backgroundView removeFromSuperview];//your code 41 | }]; 42 | ``` 43 | 44 | - Use in iOS10 45 | 46 | Open "Info.plist" file in your project and add 47 | 48 | ```xml 49 | NSCameraUsageDescription 50 | cameraDesciption 51 | 52 | NSPhotoLibraryUsageDescription 53 | cameraDesciption 54 | ``` 55 | 56 | - Change style of action button 57 | 58 | ```objective-c 59 | #import "CDZImagePickerActionsItem.h" 60 | ``` 61 | 62 | ​ And init the actionArray with CDZImagePickerActionItem with title, action, image and order you want. 63 | 64 | ```objective-c 65 | imagePickerController.actionArray = [NSMutableArray arrayWithObjects: [[CDZImagePickerActionsItem alloc]initWithTitle:@"打开设备上的图片" withActionType:CDZImagePickerLibraryAction withImage:[UIImage imageNamed:@"phone-icon.png"]], 66 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"相机" withActionType:CDZImagePickerCameraAction withImage:[UIImage imageNamed:@"camera-icon.png"]] 67 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"打开最新图片" withActionType:CDZImagePickerRecentAction withImage:[UIImage imageNamed:@"clock-icon.png"]], nil]; 68 | ``` 69 | 70 | ## Articles 71 | 72 | 73 | 74 | [iOS中写一个仿Snapseed的ImagePickerController(照片选择器 )](http://www.jianshu.com/p/e8e23e9cc67d) 75 | 76 | [iOS中权限封装小tips和监测相册变化](http://www.jianshu.com/p/d1e8366c0e10) 77 | 78 | ## Requirements 79 | 80 | 81 | 82 | iOS 8.0 Above 83 | 84 | ## TODO 85 | 86 | - Memory optimize 87 | 88 | ## Contact 89 | 90 | - Open a issue 91 | - QQ:757765420 92 | - Email:nemocdz@gmail.com 93 | - Weibo:[@Nemocdz](http://weibo.com/nemocdz) 94 | 95 | ## License 96 | 97 | CDZImagePicker is available under the MIT license. See the LICENSE file for more info. 98 | 99 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CDZImagePicker/CDZImagePickerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerView.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | #import 9 | #import 10 | #import 11 | 12 | #import "CDZImagePickerViewController.h" 13 | 14 | #import "CDZImagePickerActionsItem.h" 15 | #import "CDZImagePickerActionsDataSource.h" 16 | 17 | #import "CDZImagePIckerPhotosCell.h" 18 | #import "CDZImagePickerPhotosDataSource.h" 19 | 20 | @interface CDZImagePickerViewController () 21 | 22 | @property (nonatomic ,copy) CDZImageResultBlock block; 23 | 24 | @property (nonatomic ,strong) UIImage *resultImage; 25 | @property (nonatomic ,strong) PHFetchResult *imageAssetsResult; 26 | 27 | @property (nonatomic ,strong) UICollectionView *photosView; 28 | @property (nonatomic ,strong) UITableView *actionView; 29 | @property (nonatomic ,strong) UIView *backgroundView; 30 | 31 | @property (nonatomic ,strong) CDZImagePickerActionsDataSource *actionsDataSource; 32 | @property (nonatomic ,strong) CDZImagePickerPhotosDataSource *photosDataSource; 33 | @property (nonatomic ,strong) UICollectionViewFlowLayout *photosFlowLayout; 34 | @end 35 | 36 | 37 | @implementation CDZImagePickerViewController 38 | 39 | #pragma mark - about init 40 | - (void)viewDidLoad{ 41 | [super viewDidLoad]; 42 | [[PHPhotoLibrary sharedPhotoLibrary]registerChangeObserver:self]; 43 | [self.view addSubview:self.backgroundView]; 44 | [self.view addSubview:self.actionView]; 45 | if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) { 46 | [self.view addSubview:self.photosView]; 47 | } 48 | 49 | } 50 | 51 | 52 | - (void)dealloc{ 53 | self.block(self.resultImage); 54 | [[PHPhotoLibrary sharedPhotoLibrary]unregisterChangeObserver:self]; 55 | NSLog(@"ImagePicker已销毁"); 56 | } 57 | 58 | 59 | - (void)openPickerInController:(UIViewController *)controller withImageBlock:(CDZImageResultBlock)imageBlock{ 60 | self.modalPresentationStyle = UIModalPresentationOverCurrentContext;//iOS8上默认presentviewcontroller不透明,需设置style 61 | self.block = imageBlock; 62 | if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusNotDetermined){ 63 | [self showPermissionAlertInController:controller]; 64 | } 65 | else { 66 | [controller presentViewController:self animated:YES completion:nil]; 67 | } 68 | } 69 | 70 | #pragma mark - event response 71 | - (void)dissPicker:(UIGestureRecognizer *)gesture{ 72 | [self dismissViewControllerAnimated:YES completion:nil]; 73 | NSLog(@"点击空白处消失"); 74 | } 75 | 76 | - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ 77 | if(!error){ 78 | NSLog(@"照片保存成功"); 79 | }else{ 80 | NSLog(@"照片保存失败"); 81 | } 82 | } 83 | 84 | 85 | #pragma mark - actions 86 | - (void)doActionsWithType:(CDZImagePickerActionType)type{ 87 | switch (type) { 88 | case CDZImagePickerCameraAction: 89 | [self openCamera]; 90 | break; 91 | case CDZImagePickerRecentAction: 92 | [self openRecentImage]; 93 | break; 94 | case CDZImagePickerLibraryAction: 95 | [self openLibrary]; 96 | break; 97 | case CDZImagePickerCloseAction: 98 | [self closeAction]; 99 | break; 100 | } 101 | } 102 | 103 | - (void)openCamera{ 104 | if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 105 | UIImagePickerController *pickerController = [[UIImagePickerController alloc]init]; 106 | pickerController.delegate = self; 107 | pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 108 | [self presentViewController:pickerController animated:NO completion:nil]; 109 | NSLog(@"打开相机"); 110 | } 111 | } 112 | 113 | - (void)openLibrary{ 114 | UIImagePickerController *pickerController = [[UIImagePickerController alloc]init]; 115 | pickerController.delegate = self; 116 | pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 117 | [self presentViewController:pickerController animated:NO completion:nil]; 118 | NSLog(@"打开图库"); 119 | 120 | } 121 | 122 | - (void)closeAction{ 123 | [self dismissViewControllerAnimated:YES completion:nil]; 124 | NSLog(@"关闭按钮"); 125 | } 126 | 127 | 128 | - (void)openRecentImage{ 129 | if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized){ 130 | [[PHImageManager defaultManager]requestImageForAsset:self.photosDataSource.itemsArray[0] targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 131 | self.resultImage = result; 132 | [self dismissViewControllerAnimated:YES completion:nil]; 133 | NSLog(@"打开最新图片"); 134 | }]; 135 | } 136 | } 137 | 138 | 139 | #pragma mark - private methods 140 | 141 | - (void)showPermissionAlertInController:(UIViewController *)controller{ 142 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"需要你的图库的权限" preferredStyle:UIAlertControllerStyleAlert]; 143 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 144 | [controller presentViewController:self animated:YES completion:nil]; 145 | }]; 146 | UIAlertAction *requestAction = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 147 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 148 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { 149 | if (status == PHAuthorizationStatusAuthorized) { 150 | NSLog(@"用户同意授权相册"); 151 | }else { 152 | NSLog(@"用户拒绝授权相册"); 153 | } 154 | dispatch_async(dispatch_get_main_queue(), ^{ 155 | [controller presentViewController:self animated:YES completion:nil]; 156 | }); 157 | }]; 158 | 159 | }); 160 | }]; 161 | [alert addAction:cancelAction]; 162 | [alert addAction:requestAction]; 163 | [controller presentViewController:alert animated:YES completion:nil]; 164 | } 165 | 166 | - (NSArray *)getImageAssets{ 167 | self.imageAssetsResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:nil]; 168 | NSMutableArray *assets = [NSMutableArray new]; 169 | for (PHAsset *asset in self.imageAssetsResult){ 170 | [assets insertObject:asset atIndex:0]; 171 | } 172 | return assets; 173 | } 174 | 175 | - (void)photoLibraryDidChange:(PHChange *)changeInfo { 176 | dispatch_async(dispatch_get_main_queue(), ^{ 177 | PHFetchResultChangeDetails *changes = [changeInfo changeDetailsForFetchResult:self.imageAssetsResult]; 178 | if (changes) { 179 | self.photosDataSource.itemsArray = [self getImageAssets]; 180 | [self.photosView reloadData]; 181 | } 182 | }); 183 | } 184 | 185 | 186 | #pragma mark - imagePickerController delegate 187 | 188 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(nonnull NSDictionary *)info{ 189 | UIImage *image = info[UIImagePickerControllerOriginalImage]; 190 | if(picker.sourceType == UIImagePickerControllerSourceTypeCamera){ 191 | UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 192 | } 193 | self.resultImage = image; 194 | [picker dismissViewControllerAnimated:NO completion:nil]; 195 | [self dismissViewControllerAnimated:YES completion:nil]; 196 | NSLog(@"从相机或图库获取图片"); 197 | } 198 | 199 | #pragma mark - tableViewDelegate 200 | 201 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 202 | return actionsViewCellHeight; 203 | } 204 | 205 | 206 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 207 | CDZImagePickerActionsItem *item = self.actionsDataSource.itemArray[indexPath.row]; 208 | [self doActionsWithType:item.actionType]; 209 | } 210 | 211 | #pragma mark - collectionViewDelegateFlowLayout 212 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ 213 | PHAsset *asset = self.photosDataSource.itemsArray[indexPath.row]; 214 | CGFloat height = photosViewHeight - 2 * photosViewInset; 215 | CGFloat aspectRatio = asset.pixelWidth / (CGFloat)asset.pixelHeight; 216 | CGFloat width = height * aspectRatio; 217 | CGSize size = CGSizeMake(width, height); 218 | return size; 219 | } 220 | 221 | - (UIEdgeInsets) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ 222 | return UIEdgeInsetsMake(photosViewInset, photosViewInset, photosViewInset, photosViewInset); 223 | } 224 | 225 | - (CGFloat) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{ 226 | return photosViewInset; 227 | } 228 | 229 | #pragma mark - collectionViewDelegate 230 | 231 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 232 | [[PHImageManager defaultManager]requestImageForAsset:self.photosDataSource.itemsArray[indexPath.row] targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 233 | self.resultImage = result; 234 | [self dismissViewControllerAnimated:YES completion:nil]; 235 | NSLog(@"已选择图片"); 236 | }]; 237 | } 238 | 239 | #pragma views setter&getter 240 | - (UICollectionView *)photosView{ 241 | if (!_photosView){ 242 | CGFloat actionsViewHeight = actionsViewCellHeight * self.actionArray.count; 243 | _photosView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT - actionsViewHeight - photosViewHeight , SCREEN_WIDTH, photosViewHeight) collectionViewLayout:self.photosFlowLayout]; 244 | _photosView.delegate = self; 245 | _photosView.dataSource = self.photosDataSource; 246 | _photosView.backgroundColor = [UIColor whiteColor]; 247 | _photosView.showsHorizontalScrollIndicator = NO; 248 | [_photosView registerClass:[CDZImagePickerPhotosCell class] forCellWithReuseIdentifier:NSStringFromClass([CDZImagePickerPhotosCell class])]; 249 | } 250 | return _photosView; 251 | } 252 | 253 | 254 | - (UITableView *)actionView{ 255 | if (!_actionView) { 256 | CGFloat actionsViewHeight = actionsViewCellHeight * self.actionArray.count; 257 | _actionView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT - actionsViewHeight ,SCREEN_WIDTH, actionsViewHeight) style:UITableViewStylePlain]; 258 | _actionView.scrollEnabled = NO; //不需要滑动 259 | _actionView.separatorStyle = UITableViewCellSeparatorStyleNone; //分割线去除 260 | _actionView.delegate = self; 261 | _actionView.dataSource = self.actionsDataSource; 262 | } 263 | return _actionView; 264 | } 265 | 266 | - (UIView *)backgroundView{ 267 | if (!_backgroundView){ 268 | CGFloat actionsViewHeight = actionsViewCellHeight * self.actionArray.count; 269 | _backgroundView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - photosViewHeight - actionsViewHeight)]; 270 | _backgroundView.opaque = YES; 271 | _backgroundView.userInteractionEnabled = YES; 272 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dissPicker:)]; 273 | [_backgroundView addGestureRecognizer:tap]; 274 | } 275 | return _backgroundView; 276 | } 277 | 278 | #pragma mark - property setter&getter 279 | 280 | - (UICollectionViewFlowLayout *)photosFlowLayout{ 281 | if (!_photosFlowLayout) { 282 | _photosFlowLayout = [UICollectionViewFlowLayout new]; 283 | _photosFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; //水平滚动 284 | } 285 | return _photosFlowLayout; 286 | } 287 | 288 | 289 | - (CDZImagePickerActionsDataSource *)actionsDataSource{ 290 | if (!_actionsDataSource) { 291 | _actionsDataSource = [[CDZImagePickerActionsDataSource alloc]init]; 292 | _actionsDataSource.itemArray = self.actionArray; 293 | } 294 | return _actionsDataSource; 295 | } 296 | 297 | - (CDZImagePickerPhotosDataSource *)photosDataSource{ 298 | if (!_photosDataSource){ 299 | _photosDataSource = [[CDZImagePickerPhotosDataSource alloc]init]; 300 | _photosDataSource.itemsArray = [self getImageAssets]; 301 | } 302 | return _photosDataSource; 303 | } 304 | 305 | - (NSMutableArray *)actionArray{ 306 | if (!_actionArray){ 307 | _actionArray = [NSMutableArray arrayWithObjects: 308 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"图库" withActionType:CDZImagePickerLibraryAction withImage:nil], 309 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"相机" withActionType:CDZImagePickerCameraAction withImage:nil], 310 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"取消" withActionType:CDZImagePickerCloseAction withImage:nil], 311 | nil]; 312 | } 313 | return _actionArray; 314 | } 315 | 316 | 317 | 318 | @end 319 | -------------------------------------------------------------------------------- /CDZImagePickerDemo/CDZImagePicker/CDZImagePickerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDZImagePickerView.m 3 | // CDZImagePickerDemo 4 | // 5 | // Created by Nemocdz on 2016/11/23. 6 | // Copyright © 2016年 Nemocdz. All rights reserved. 7 | // 8 | #import 9 | #import 10 | #import 11 | 12 | #import "CDZImagePickerViewController.h" 13 | 14 | #import "CDZImagePickerActionsItem.h" 15 | #import "CDZImagePickerActionsDataSource.h" 16 | 17 | #import "CDZImagePIckerPhotosCell.h" 18 | #import "CDZImagePickerPhotosDataSource.h" 19 | 20 | @interface CDZImagePickerViewController () 21 | 22 | @property (nonatomic ,copy) CDZImageResultBlock block; 23 | 24 | @property (nonatomic ,strong) UIImage *resultImage; 25 | @property (nonatomic ,strong) PHFetchResult *imageAssetsResult; 26 | 27 | @property (nonatomic ,strong) UICollectionView *photosView; 28 | @property (nonatomic ,strong) UITableView *actionView; 29 | @property (nonatomic ,strong) UIView *backgroundView; 30 | 31 | @property (nonatomic ,strong) CDZImagePickerActionsDataSource *actionsDataSource; 32 | @property (nonatomic ,strong) CDZImagePickerPhotosDataSource *photosDataSource; 33 | @property (nonatomic ,strong) UICollectionViewFlowLayout *photosFlowLayout; 34 | @end 35 | 36 | 37 | @implementation CDZImagePickerViewController 38 | 39 | #pragma mark - about init 40 | - (void)viewDidLoad{ 41 | [super viewDidLoad]; 42 | [[PHPhotoLibrary sharedPhotoLibrary]registerChangeObserver:self]; 43 | [self.view addSubview:self.backgroundView]; 44 | [self.view addSubview:self.actionView]; 45 | if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized) { 46 | [self.view addSubview:self.photosView]; 47 | } 48 | 49 | } 50 | 51 | 52 | - (void)dealloc{ 53 | self.block(self.resultImage); 54 | [[PHPhotoLibrary sharedPhotoLibrary]unregisterChangeObserver:self]; 55 | NSLog(@"ImagePicker已销毁"); 56 | } 57 | 58 | 59 | - (void)openPickerInController:(UIViewController *)controller withImageBlock:(CDZImageResultBlock)imageBlock{ 60 | self.modalPresentationStyle = UIModalPresentationOverCurrentContext;//iOS8上默认presentviewcontroller不透明,需设置style 61 | self.block = imageBlock; 62 | if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusNotDetermined){ 63 | [self showPermissionAlertInController:controller]; 64 | } 65 | else { 66 | [controller presentViewController:self animated:YES completion:nil]; 67 | } 68 | } 69 | 70 | #pragma mark - event response 71 | - (void)dissPicker:(UIGestureRecognizer *)gesture{ 72 | [self dismissViewControllerAnimated:YES completion:nil]; 73 | NSLog(@"点击空白处消失"); 74 | } 75 | 76 | - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{ 77 | if(!error){ 78 | NSLog(@"照片保存成功"); 79 | }else{ 80 | NSLog(@"照片保存失败"); 81 | } 82 | } 83 | 84 | 85 | #pragma mark - actions 86 | - (void)doActionsWithType:(CDZImagePickerActionType)type{ 87 | switch (type) { 88 | case CDZImagePickerCameraAction: 89 | [self openCamera]; 90 | break; 91 | case CDZImagePickerRecentAction: 92 | [self openRecentImage]; 93 | break; 94 | case CDZImagePickerLibraryAction: 95 | [self openLibrary]; 96 | break; 97 | case CDZImagePickerCloseAction: 98 | [self closeAction]; 99 | break; 100 | } 101 | } 102 | 103 | - (void)openCamera{ 104 | if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 105 | UIImagePickerController *pickerController = [[UIImagePickerController alloc]init]; 106 | pickerController.delegate = self; 107 | pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 108 | [self presentViewController:pickerController animated:NO completion:nil]; 109 | NSLog(@"打开相机"); 110 | } 111 | } 112 | 113 | - (void)openLibrary{ 114 | UIImagePickerController *pickerController = [[UIImagePickerController alloc]init]; 115 | pickerController.delegate = self; 116 | pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 117 | [self presentViewController:pickerController animated:NO completion:nil]; 118 | NSLog(@"打开图库"); 119 | 120 | } 121 | 122 | - (void)closeAction{ 123 | [self dismissViewControllerAnimated:YES completion:nil]; 124 | NSLog(@"关闭按钮"); 125 | } 126 | 127 | 128 | - (void)openRecentImage{ 129 | if ([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized){ 130 | [[PHImageManager defaultManager]requestImageForAsset:self.photosDataSource.itemsArray[0] targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 131 | self.resultImage = result; 132 | [self dismissViewControllerAnimated:YES completion:nil]; 133 | NSLog(@"打开最新图片"); 134 | }]; 135 | } 136 | } 137 | 138 | 139 | #pragma mark - private methods 140 | 141 | - (void)showPermissionAlertInController:(UIViewController *)controller{ 142 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"需要你的图库的权限" preferredStyle:UIAlertControllerStyleAlert]; 143 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { 144 | [controller presentViewController:self animated:YES completion:nil]; 145 | }]; 146 | UIAlertAction *requestAction = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 147 | dispatch_async(dispatch_get_global_queue(0, 0), ^{ 148 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { 149 | if (status == PHAuthorizationStatusAuthorized) { 150 | NSLog(@"用户同意授权相册"); 151 | }else { 152 | NSLog(@"用户拒绝授权相册"); 153 | } 154 | dispatch_async(dispatch_get_main_queue(), ^{ 155 | [controller presentViewController:self animated:YES completion:nil]; 156 | }); 157 | }]; 158 | 159 | }); 160 | }]; 161 | [alert addAction:cancelAction]; 162 | [alert addAction:requestAction]; 163 | [controller presentViewController:alert animated:YES completion:nil]; 164 | } 165 | 166 | - (NSArray *)getImageAssets{ 167 | self.imageAssetsResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:nil]; 168 | NSMutableArray *assets = [NSMutableArray new]; 169 | for (PHAsset *asset in self.imageAssetsResult){ 170 | [assets insertObject:asset atIndex:0]; 171 | } 172 | return assets; 173 | } 174 | 175 | - (void)photoLibraryDidChange:(PHChange *)changeInfo { 176 | dispatch_async(dispatch_get_main_queue(), ^{ 177 | PHFetchResultChangeDetails *changes = [changeInfo changeDetailsForFetchResult:self.imageAssetsResult]; 178 | if (changes) { 179 | self.photosDataSource.itemsArray = [self getImageAssets]; 180 | [self.photosView reloadData]; 181 | } 182 | }); 183 | } 184 | 185 | 186 | #pragma mark - imagePickerController delegate 187 | 188 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(nonnull NSDictionary *)info{ 189 | UIImage *image = info[UIImagePickerControllerOriginalImage]; 190 | if(picker.sourceType == UIImagePickerControllerSourceTypeCamera){ 191 | UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 192 | } 193 | self.resultImage = image; 194 | [picker dismissViewControllerAnimated:NO completion:nil]; 195 | [self dismissViewControllerAnimated:YES completion:nil]; 196 | NSLog(@"从相机或图库获取图片"); 197 | } 198 | 199 | #pragma mark - tableViewDelegate 200 | 201 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 202 | return actionsViewCellHeight; 203 | } 204 | 205 | 206 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 207 | CDZImagePickerActionsItem *item = self.actionsDataSource.itemArray[indexPath.row]; 208 | [self doActionsWithType:item.actionType]; 209 | } 210 | 211 | #pragma mark - collectionViewDelegateFlowLayout 212 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ 213 | PHAsset *asset = self.photosDataSource.itemsArray[indexPath.row]; 214 | CGFloat height = photosViewHeight - 2 * photosViewInset; 215 | CGFloat aspectRatio = asset.pixelWidth / (CGFloat)asset.pixelHeight; 216 | CGFloat width = height * aspectRatio; 217 | CGSize size = CGSizeMake(width, height); 218 | return size; 219 | } 220 | 221 | - (UIEdgeInsets) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ 222 | return UIEdgeInsetsMake(photosViewInset, photosViewInset, photosViewInset, photosViewInset); 223 | } 224 | 225 | - (CGFloat) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{ 226 | return photosViewInset; 227 | } 228 | 229 | #pragma mark - collectionViewDelegate 230 | 231 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ 232 | [[PHImageManager defaultManager]requestImageForAsset:self.photosDataSource.itemsArray[indexPath.row] targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) { 233 | self.resultImage = result; 234 | [self dismissViewControllerAnimated:YES completion:nil]; 235 | NSLog(@"已选择图片"); 236 | }]; 237 | } 238 | 239 | #pragma views setter&getter 240 | - (UICollectionView *)photosView{ 241 | if (!_photosView){ 242 | CGFloat actionsViewHeight = actionsViewCellHeight * self.actionArray.count; 243 | _photosView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT - actionsViewHeight - photosViewHeight , SCREEN_WIDTH, photosViewHeight) collectionViewLayout:self.photosFlowLayout]; 244 | _photosView.delegate = self; 245 | _photosView.dataSource = self.photosDataSource; 246 | _photosView.backgroundColor = [UIColor whiteColor]; 247 | _photosView.showsHorizontalScrollIndicator = NO; 248 | [_photosView registerClass:[CDZImagePickerPhotosCell class] forCellWithReuseIdentifier:NSStringFromClass([CDZImagePickerPhotosCell class])]; 249 | } 250 | return _photosView; 251 | } 252 | 253 | 254 | - (UITableView *)actionView{ 255 | if (!_actionView) { 256 | CGFloat actionsViewHeight = actionsViewCellHeight * self.actionArray.count; 257 | _actionView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT - actionsViewHeight ,SCREEN_WIDTH, actionsViewHeight) style:UITableViewStylePlain]; 258 | _actionView.scrollEnabled = NO; //不需要滑动 259 | _actionView.separatorStyle = UITableViewCellSeparatorStyleNone; //分割线去除 260 | _actionView.delegate = self; 261 | _actionView.dataSource = self.actionsDataSource; 262 | } 263 | return _actionView; 264 | } 265 | 266 | - (UIView *)backgroundView{ 267 | if (!_backgroundView){ 268 | CGFloat actionsViewHeight = actionsViewCellHeight * self.actionArray.count; 269 | _backgroundView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - photosViewHeight - actionsViewHeight)]; 270 | _backgroundView.opaque = YES; 271 | _backgroundView.userInteractionEnabled = YES; 272 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dissPicker:)]; 273 | [_backgroundView addGestureRecognizer:tap]; 274 | } 275 | return _backgroundView; 276 | } 277 | 278 | #pragma mark - property setter&getter 279 | 280 | - (UICollectionViewFlowLayout *)photosFlowLayout{ 281 | if (!_photosFlowLayout) { 282 | _photosFlowLayout = [UICollectionViewFlowLayout new]; 283 | _photosFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; //水平滚动 284 | } 285 | return _photosFlowLayout; 286 | } 287 | 288 | 289 | - (CDZImagePickerActionsDataSource *)actionsDataSource{ 290 | if (!_actionsDataSource) { 291 | _actionsDataSource = [[CDZImagePickerActionsDataSource alloc]init]; 292 | _actionsDataSource.itemArray = self.actionArray; 293 | } 294 | return _actionsDataSource; 295 | } 296 | 297 | - (CDZImagePickerPhotosDataSource *)photosDataSource{ 298 | if (!_photosDataSource){ 299 | _photosDataSource = [[CDZImagePickerPhotosDataSource alloc]init]; 300 | _photosDataSource.itemsArray = [self getImageAssets]; 301 | } 302 | return _photosDataSource; 303 | } 304 | 305 | - (NSMutableArray *)actionArray{ 306 | if (!_actionArray){ 307 | _actionArray = [NSMutableArray arrayWithObjects: 308 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"图库" withActionType:CDZImagePickerLibraryAction withImage:nil], 309 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"相机" withActionType:CDZImagePickerCameraAction withImage:nil], 310 | [[CDZImagePickerActionsItem alloc]initWithTitle:@"取消" withActionType:CDZImagePickerCloseAction withImage:nil], 311 | nil]; 312 | } 313 | return _actionArray; 314 | } 315 | 316 | 317 | 318 | @end 319 | -------------------------------------------------------------------------------- /CDZImagePickerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DA8F9CC71DE5C92D0050A1EE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8F9CC61DE5C92D0050A1EE /* main.m */; }; 11 | DA8F9CCA1DE5C92D0050A1EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8F9CC91DE5C92D0050A1EE /* AppDelegate.m */; }; 12 | DA8F9CCD1DE5C92D0050A1EE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8F9CCC1DE5C92D0050A1EE /* ViewController.m */; }; 13 | DA8F9CD01DE5C92D0050A1EE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DA8F9CCE1DE5C92D0050A1EE /* Main.storyboard */; }; 14 | DA8F9CD21DE5C92D0050A1EE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA8F9CD11DE5C92D0050A1EE /* Assets.xcassets */; }; 15 | DA8F9CD51DE5C92D0050A1EE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DA8F9CD31DE5C92D0050A1EE /* LaunchScreen.storyboard */; }; 16 | DAB48B521E30D02800CF7F6C /* CDZImagePickerActionsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB48B451E30D02800CF7F6C /* CDZImagePickerActionsCell.m */; }; 17 | DAB48B531E30D02800CF7F6C /* CDZImagePickerActionsDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB48B471E30D02800CF7F6C /* CDZImagePickerActionsDataSource.m */; }; 18 | DAB48B541E30D02800CF7F6C /* CDZImagePickerActionsItem.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB48B491E30D02800CF7F6C /* CDZImagePickerActionsItem.m */; }; 19 | DAB48B551E30D02800CF7F6C /* CDZImagePickerPhotosCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB48B4D1E30D02800CF7F6C /* CDZImagePickerPhotosCell.m */; }; 20 | DAB48B561E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB48B4F1E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.m */; }; 21 | DAB48B571E30D02800CF7F6C /* CDZImagePickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB48B511E30D02800CF7F6C /* CDZImagePickerViewController.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | DA8F9CC21DE5C92D0050A1EE /* CDZImagePickerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CDZImagePickerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | DA8F9CC61DE5C92D0050A1EE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 27 | DA8F9CC81DE5C92D0050A1EE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 28 | DA8F9CC91DE5C92D0050A1EE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 29 | DA8F9CCB1DE5C92D0050A1EE /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 30 | DA8F9CCC1DE5C92D0050A1EE /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 31 | DA8F9CCF1DE5C92D0050A1EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 32 | DA8F9CD11DE5C92D0050A1EE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 33 | DA8F9CD41DE5C92D0050A1EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 34 | DA8F9CD61DE5C92D0050A1EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | DAB48B441E30D02800CF7F6C /* CDZImagePickerActionsCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerActionsCell.h; sourceTree = ""; }; 36 | DAB48B451E30D02800CF7F6C /* CDZImagePickerActionsCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZImagePickerActionsCell.m; sourceTree = ""; }; 37 | DAB48B461E30D02800CF7F6C /* CDZImagePickerActionsDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerActionsDataSource.h; sourceTree = ""; }; 38 | DAB48B471E30D02800CF7F6C /* CDZImagePickerActionsDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZImagePickerActionsDataSource.m; sourceTree = ""; }; 39 | DAB48B481E30D02800CF7F6C /* CDZImagePickerActionsItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerActionsItem.h; sourceTree = ""; }; 40 | DAB48B491E30D02800CF7F6C /* CDZImagePickerActionsItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZImagePickerActionsItem.m; sourceTree = ""; }; 41 | DAB48B4A1E30D02800CF7F6C /* CDZImagePickerConstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerConstant.h; sourceTree = ""; }; 42 | DAB48B4C1E30D02800CF7F6C /* CDZImagePickerPhotosCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerPhotosCell.h; sourceTree = ""; }; 43 | DAB48B4D1E30D02800CF7F6C /* CDZImagePickerPhotosCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZImagePickerPhotosCell.m; sourceTree = ""; }; 44 | DAB48B4E1E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerPhotosDataSource.h; sourceTree = ""; }; 45 | DAB48B4F1E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZImagePickerPhotosDataSource.m; sourceTree = ""; }; 46 | DAB48B501E30D02800CF7F6C /* CDZImagePickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDZImagePickerViewController.h; sourceTree = ""; }; 47 | DAB48B511E30D02800CF7F6C /* CDZImagePickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDZImagePickerViewController.m; sourceTree = ""; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | DA8F9CBF1DE5C92D0050A1EE /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | DA8F9CB91DE5C92D0050A1EE = { 62 | isa = PBXGroup; 63 | children = ( 64 | DAB48B341E30C80A00CF7F6C /* CDZImagePickerDemo */, 65 | DA8F9CC31DE5C92D0050A1EE /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | DA8F9CC31DE5C92D0050A1EE /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | DA8F9CC21DE5C92D0050A1EE /* CDZImagePickerDemo.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | DA8F9CC51DE5C92D0050A1EE /* Supporting Files */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | DA8F9CC61DE5C92D0050A1EE /* main.m */, 81 | ); 82 | name = "Supporting Files"; 83 | sourceTree = ""; 84 | }; 85 | DAB48B341E30C80A00CF7F6C /* CDZImagePickerDemo */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | DAB48B421E30D02800CF7F6C /* CDZImagePicker */, 89 | DA8F9CC81DE5C92D0050A1EE /* AppDelegate.h */, 90 | DA8F9CC91DE5C92D0050A1EE /* AppDelegate.m */, 91 | DA8F9CCB1DE5C92D0050A1EE /* ViewController.h */, 92 | DA8F9CCC1DE5C92D0050A1EE /* ViewController.m */, 93 | DA8F9CCE1DE5C92D0050A1EE /* Main.storyboard */, 94 | DA8F9CD11DE5C92D0050A1EE /* Assets.xcassets */, 95 | DA8F9CD31DE5C92D0050A1EE /* LaunchScreen.storyboard */, 96 | DA8F9CD61DE5C92D0050A1EE /* Info.plist */, 97 | DA8F9CC51DE5C92D0050A1EE /* Supporting Files */, 98 | ); 99 | path = CDZImagePickerDemo; 100 | sourceTree = ""; 101 | }; 102 | DAB48B421E30D02800CF7F6C /* CDZImagePicker */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | DAB48B431E30D02800CF7F6C /* CDZImagePickerActionsView */, 106 | DAB48B4A1E30D02800CF7F6C /* CDZImagePickerConstant.h */, 107 | DAB48B4B1E30D02800CF7F6C /* CDZImagePickerPhotosView */, 108 | DAB48B501E30D02800CF7F6C /* CDZImagePickerViewController.h */, 109 | DAB48B511E30D02800CF7F6C /* CDZImagePickerViewController.m */, 110 | ); 111 | path = CDZImagePicker; 112 | sourceTree = ""; 113 | }; 114 | DAB48B431E30D02800CF7F6C /* CDZImagePickerActionsView */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | DAB48B441E30D02800CF7F6C /* CDZImagePickerActionsCell.h */, 118 | DAB48B451E30D02800CF7F6C /* CDZImagePickerActionsCell.m */, 119 | DAB48B461E30D02800CF7F6C /* CDZImagePickerActionsDataSource.h */, 120 | DAB48B471E30D02800CF7F6C /* CDZImagePickerActionsDataSource.m */, 121 | DAB48B481E30D02800CF7F6C /* CDZImagePickerActionsItem.h */, 122 | DAB48B491E30D02800CF7F6C /* CDZImagePickerActionsItem.m */, 123 | ); 124 | path = CDZImagePickerActionsView; 125 | sourceTree = ""; 126 | }; 127 | DAB48B4B1E30D02800CF7F6C /* CDZImagePickerPhotosView */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | DAB48B4C1E30D02800CF7F6C /* CDZImagePickerPhotosCell.h */, 131 | DAB48B4D1E30D02800CF7F6C /* CDZImagePickerPhotosCell.m */, 132 | DAB48B4E1E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.h */, 133 | DAB48B4F1E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.m */, 134 | ); 135 | path = CDZImagePickerPhotosView; 136 | sourceTree = ""; 137 | }; 138 | /* End PBXGroup section */ 139 | 140 | /* Begin PBXNativeTarget section */ 141 | DA8F9CC11DE5C92D0050A1EE /* CDZImagePickerDemo */ = { 142 | isa = PBXNativeTarget; 143 | buildConfigurationList = DA8F9CD91DE5C92D0050A1EE /* Build configuration list for PBXNativeTarget "CDZImagePickerDemo" */; 144 | buildPhases = ( 145 | DA8F9CBE1DE5C92D0050A1EE /* Sources */, 146 | DA8F9CBF1DE5C92D0050A1EE /* Frameworks */, 147 | DA8F9CC01DE5C92D0050A1EE /* Resources */, 148 | ); 149 | buildRules = ( 150 | ); 151 | dependencies = ( 152 | ); 153 | name = CDZImagePickerDemo; 154 | productName = CDZImagePickerDemo; 155 | productReference = DA8F9CC21DE5C92D0050A1EE /* CDZImagePickerDemo.app */; 156 | productType = "com.apple.product-type.application"; 157 | }; 158 | /* End PBXNativeTarget section */ 159 | 160 | /* Begin PBXProject section */ 161 | DA8F9CBA1DE5C92D0050A1EE /* Project object */ = { 162 | isa = PBXProject; 163 | attributes = { 164 | LastUpgradeCheck = 0810; 165 | ORGANIZATIONNAME = Nemocdz; 166 | TargetAttributes = { 167 | DA8F9CC11DE5C92D0050A1EE = { 168 | CreatedOnToolsVersion = 8.1; 169 | DevelopmentTeam = 8HQ2P3SCVF; 170 | ProvisioningStyle = Automatic; 171 | }; 172 | }; 173 | }; 174 | buildConfigurationList = DA8F9CBD1DE5C92D0050A1EE /* Build configuration list for PBXProject "CDZImagePickerDemo" */; 175 | compatibilityVersion = "Xcode 3.2"; 176 | developmentRegion = English; 177 | hasScannedForEncodings = 0; 178 | knownRegions = ( 179 | en, 180 | Base, 181 | ); 182 | mainGroup = DA8F9CB91DE5C92D0050A1EE; 183 | productRefGroup = DA8F9CC31DE5C92D0050A1EE /* Products */; 184 | projectDirPath = ""; 185 | projectRoot = ""; 186 | targets = ( 187 | DA8F9CC11DE5C92D0050A1EE /* CDZImagePickerDemo */, 188 | ); 189 | }; 190 | /* End PBXProject section */ 191 | 192 | /* Begin PBXResourcesBuildPhase section */ 193 | DA8F9CC01DE5C92D0050A1EE /* Resources */ = { 194 | isa = PBXResourcesBuildPhase; 195 | buildActionMask = 2147483647; 196 | files = ( 197 | DA8F9CD51DE5C92D0050A1EE /* LaunchScreen.storyboard in Resources */, 198 | DA8F9CD21DE5C92D0050A1EE /* Assets.xcassets in Resources */, 199 | DA8F9CD01DE5C92D0050A1EE /* Main.storyboard in Resources */, 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | /* End PBXResourcesBuildPhase section */ 204 | 205 | /* Begin PBXSourcesBuildPhase section */ 206 | DA8F9CBE1DE5C92D0050A1EE /* Sources */ = { 207 | isa = PBXSourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | DAB48B571E30D02800CF7F6C /* CDZImagePickerViewController.m in Sources */, 211 | DA8F9CCD1DE5C92D0050A1EE /* ViewController.m in Sources */, 212 | DAB48B521E30D02800CF7F6C /* CDZImagePickerActionsCell.m in Sources */, 213 | DAB48B561E30D02800CF7F6C /* CDZImagePickerPhotosDataSource.m in Sources */, 214 | DAB48B541E30D02800CF7F6C /* CDZImagePickerActionsItem.m in Sources */, 215 | DAB48B551E30D02800CF7F6C /* CDZImagePickerPhotosCell.m in Sources */, 216 | DAB48B531E30D02800CF7F6C /* CDZImagePickerActionsDataSource.m in Sources */, 217 | DA8F9CCA1DE5C92D0050A1EE /* AppDelegate.m in Sources */, 218 | DA8F9CC71DE5C92D0050A1EE /* main.m in Sources */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | /* End PBXSourcesBuildPhase section */ 223 | 224 | /* Begin PBXVariantGroup section */ 225 | DA8F9CCE1DE5C92D0050A1EE /* Main.storyboard */ = { 226 | isa = PBXVariantGroup; 227 | children = ( 228 | DA8F9CCF1DE5C92D0050A1EE /* Base */, 229 | ); 230 | name = Main.storyboard; 231 | sourceTree = ""; 232 | }; 233 | DA8F9CD31DE5C92D0050A1EE /* LaunchScreen.storyboard */ = { 234 | isa = PBXVariantGroup; 235 | children = ( 236 | DA8F9CD41DE5C92D0050A1EE /* Base */, 237 | ); 238 | name = LaunchScreen.storyboard; 239 | sourceTree = ""; 240 | }; 241 | /* End PBXVariantGroup section */ 242 | 243 | /* Begin XCBuildConfiguration section */ 244 | DA8F9CD71DE5C92D0050A1EE /* Debug */ = { 245 | isa = XCBuildConfiguration; 246 | buildSettings = { 247 | ALWAYS_SEARCH_USER_PATHS = NO; 248 | CLANG_ANALYZER_NONNULL = YES; 249 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 250 | CLANG_CXX_LIBRARY = "libc++"; 251 | CLANG_ENABLE_MODULES = YES; 252 | CLANG_ENABLE_OBJC_ARC = YES; 253 | CLANG_WARN_BOOL_CONVERSION = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 256 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 257 | CLANG_WARN_EMPTY_BODY = YES; 258 | CLANG_WARN_ENUM_CONVERSION = YES; 259 | CLANG_WARN_INFINITE_RECURSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 262 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 263 | CLANG_WARN_UNREACHABLE_CODE = YES; 264 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 265 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 266 | COPY_PHASE_STRIP = NO; 267 | DEBUG_INFORMATION_FORMAT = dwarf; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | ENABLE_TESTABILITY = YES; 270 | GCC_C_LANGUAGE_STANDARD = gnu99; 271 | GCC_DYNAMIC_NO_PIC = NO; 272 | GCC_NO_COMMON_BLOCKS = YES; 273 | GCC_OPTIMIZATION_LEVEL = 0; 274 | GCC_PREPROCESSOR_DEFINITIONS = ( 275 | "DEBUG=1", 276 | "$(inherited)", 277 | ); 278 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 279 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 280 | GCC_WARN_UNDECLARED_SELECTOR = YES; 281 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 282 | GCC_WARN_UNUSED_FUNCTION = YES; 283 | GCC_WARN_UNUSED_VARIABLE = YES; 284 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 285 | MTL_ENABLE_DEBUG_INFO = YES; 286 | ONLY_ACTIVE_ARCH = YES; 287 | SDKROOT = iphoneos; 288 | }; 289 | name = Debug; 290 | }; 291 | DA8F9CD81DE5C92D0050A1EE /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ALWAYS_SEARCH_USER_PATHS = NO; 295 | CLANG_ANALYZER_NONNULL = YES; 296 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 297 | CLANG_CXX_LIBRARY = "libc++"; 298 | CLANG_ENABLE_MODULES = YES; 299 | CLANG_ENABLE_OBJC_ARC = YES; 300 | CLANG_WARN_BOOL_CONVERSION = YES; 301 | CLANG_WARN_CONSTANT_CONVERSION = YES; 302 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 303 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 304 | CLANG_WARN_EMPTY_BODY = YES; 305 | CLANG_WARN_ENUM_CONVERSION = YES; 306 | CLANG_WARN_INFINITE_RECURSION = YES; 307 | CLANG_WARN_INT_CONVERSION = YES; 308 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 309 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 310 | CLANG_WARN_UNREACHABLE_CODE = YES; 311 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 312 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 313 | COPY_PHASE_STRIP = NO; 314 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 315 | ENABLE_NS_ASSERTIONS = NO; 316 | ENABLE_STRICT_OBJC_MSGSEND = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_NO_COMMON_BLOCKS = YES; 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 326 | MTL_ENABLE_DEBUG_INFO = NO; 327 | SDKROOT = iphoneos; 328 | VALIDATE_PRODUCT = YES; 329 | }; 330 | name = Release; 331 | }; 332 | DA8F9CDA1DE5C92D0050A1EE /* Debug */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 336 | DEVELOPMENT_TEAM = 8HQ2P3SCVF; 337 | INFOPLIST_FILE = CDZImagePickerDemo/Info.plist; 338 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 339 | PRODUCT_BUNDLE_IDENTIFIER = nemocdz.CDZImagePickerDemo; 340 | PRODUCT_NAME = "$(TARGET_NAME)"; 341 | }; 342 | name = Debug; 343 | }; 344 | DA8F9CDB1DE5C92D0050A1EE /* Release */ = { 345 | isa = XCBuildConfiguration; 346 | buildSettings = { 347 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 348 | DEVELOPMENT_TEAM = 8HQ2P3SCVF; 349 | INFOPLIST_FILE = CDZImagePickerDemo/Info.plist; 350 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 351 | PRODUCT_BUNDLE_IDENTIFIER = nemocdz.CDZImagePickerDemo; 352 | PRODUCT_NAME = "$(TARGET_NAME)"; 353 | }; 354 | name = Release; 355 | }; 356 | /* End XCBuildConfiguration section */ 357 | 358 | /* Begin XCConfigurationList section */ 359 | DA8F9CBD1DE5C92D0050A1EE /* Build configuration list for PBXProject "CDZImagePickerDemo" */ = { 360 | isa = XCConfigurationList; 361 | buildConfigurations = ( 362 | DA8F9CD71DE5C92D0050A1EE /* Debug */, 363 | DA8F9CD81DE5C92D0050A1EE /* Release */, 364 | ); 365 | defaultConfigurationIsVisible = 0; 366 | defaultConfigurationName = Release; 367 | }; 368 | DA8F9CD91DE5C92D0050A1EE /* Build configuration list for PBXNativeTarget "CDZImagePickerDemo" */ = { 369 | isa = XCConfigurationList; 370 | buildConfigurations = ( 371 | DA8F9CDA1DE5C92D0050A1EE /* Debug */, 372 | DA8F9CDB1DE5C92D0050A1EE /* Release */, 373 | ); 374 | defaultConfigurationIsVisible = 0; 375 | defaultConfigurationName = Release; 376 | }; 377 | /* End XCConfigurationList section */ 378 | }; 379 | rootObject = DA8F9CBA1DE5C92D0050A1EE /* Project object */; 380 | } 381 | --------------------------------------------------------------------------------