diff --git a/DoImagePickerController.podspec b/DoImagePickerController.podspec new file mode 100644 index 0000000..843ae08 --- /dev/null +++ b/DoImagePickerController.podspec @@ -0,0 +1,22 @@ +Pod::Spec.new do |s| + + s.name = "DoImagePickerController" + s.version = "0.0.1" + s.summary = "An image picker controller with single selection and multiple selection. Support to select lots photos with panning gesture." + s.description = <<-DESC + A longer description of DoImagePickerController in Markdown format. + + * Think: Why did you write this? What is the focus? What does it do? + * CocoaPods will be using this to generate tags, and improve search results. + * Try to keep it short, snappy and to the point. + * Finally, don't worry about the indent, CocoaPods strips it! + DESC + + s.homepage = "https://github.com/donobono/DoImagePickerController" + s.license = "MIT" + s.author = "donobono" + s.source = { :git => "https://github.com/donobono/DoImagePickerController.git", :commit => "7ffcdd17dc866649f0e32e0220b64e314eee5b7e" } + s.source_files = "Classes", "Classes/**/*.{h,m}" + s.exclude_files = "Classes/Exclude" + +end diff --git a/ImagePicker/AppDelegate.h b/ImagePicker/AppDelegate.h deleted file mode 100644 index b9da92a..0000000 --- a/ImagePicker/AppDelegate.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// AppDelegate.h -// ImagePicker -// -// Created by Seungbo Cho on 2014. 1. 23.. -// Copyright (c) 2014년 Seungbo Cho. All rights reserved. -// - -#import - -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - -@end diff --git a/ImagePicker/AppDelegate.m b/ImagePicker/AppDelegate.m deleted file mode 100644 index c7bfe1b..0000000 --- a/ImagePicker/AppDelegate.m +++ /dev/null @@ -1,46 +0,0 @@ -// -// AppDelegate.m -// ImagePicker -// -// Created by Seungbo Cho on 2014. 1. 23.. -// Copyright (c) 2014년 Seungbo Cho. All rights reserved. -// - -#import "AppDelegate.h" - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - // Override point for customization after application launch. - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application -{ - // 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. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application -{ - // 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. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application -{ - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application -{ - // 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. -} - -- (void)applicationWillTerminate:(UIApplication *)application -{ - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. -} - -@end diff --git a/ImagePicker/Base.lproj/Main.storyboard b/ImagePicker/Base.lproj/Main.storyboard deleted file mode 100644 index 6ddda3d..0000000 --- a/ImagePicker/Base.lproj/Main.storyboard +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ImagePicker/DoImagePicker/AssetHelper.h b/ImagePicker/DoImagePicker/AssetHelper.h index dbd677c..f30d41d 100644 --- a/ImagePicker/DoImagePicker/AssetHelper.h +++ b/ImagePicker/DoImagePicker/AssetHelper.h @@ -11,8 +11,9 @@ #define ASSETHELPER [AssetHelper sharedAssetHelper] #define ASSET_PHOTO_THUMBNAIL 0 -#define ASSET_PHOTO_SCREEN_SIZE 1 -#define ASSET_PHOTO_FULL_RESOLUTION 2 +#define ASSET_PHOTO_ASPECT_THUMBNAIL 1 +#define ASSET_PHOTO_SCREEN_SIZE 2 +#define ASSET_PHOTO_FULL_RESOLUTION 3 @interface AssetHelper : NSObject diff --git a/ImagePicker/DoImagePicker/AssetHelper.m b/ImagePicker/DoImagePicker/AssetHelper.m index 913460a..2fbaf93 100644 --- a/ImagePicker/DoImagePicker/AssetHelper.m +++ b/ImagePicker/DoImagePicker/AssetHelper.m @@ -226,31 +226,12 @@ - (UIImage *)getImageFromAsset:(ALAsset *)asset type:(NSInteger)nType if (nType == ASSET_PHOTO_THUMBNAIL) iRef = [asset thumbnail]; + else if (nType == ASSET_PHOTO_ASPECT_THUMBNAIL) + iRef = [asset aspectRatioThumbnail]; else if (nType == ASSET_PHOTO_SCREEN_SIZE) iRef = [asset.defaultRepresentation fullScreenImage]; else if (nType == ASSET_PHOTO_FULL_RESOLUTION) - { - NSString *strXMP = asset.defaultRepresentation.metadata[@"AdjustmentXMP"]; - NSData *dXMP = [strXMP dataUsingEncoding:NSUTF8StringEncoding]; - - CIImage *image = [CIImage imageWithCGImage:asset.defaultRepresentation.fullResolutionImage]; - - NSError *error = nil; - NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:dXMP - inputImageExtent:image.extent - error:&error]; - if (error) { - NSLog(@"Error during CIFilter creation: %@", [error localizedDescription]); - } - - for (CIFilter *filter in filterArray) { - [filter setValue:image forKey:kCIInputImageKey]; - image = [filter outputImage]; - } - - UIImage *iImage = [UIImage imageWithCIImage:image scale:1.0 orientation:(UIImageOrientation)asset.defaultRepresentation.orientation]; - return iImage; - } + iRef = [asset.defaultRepresentation fullResolutionImage]; return [UIImage imageWithCGImage:iRef]; } diff --git a/ImagePicker/DoImagePicker/DoImagePickerController.h b/ImagePicker/DoImagePicker/DoImagePickerController.h index ed6e31a..3e7e53f 100644 --- a/ImagePicker/DoImagePicker/DoImagePickerController.h +++ b/ImagePicker/DoImagePicker/DoImagePickerController.h @@ -10,10 +10,10 @@ #define DO_RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1] #define DO_RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] -#define DO_MENU_BACK_COLOR DO_RGBA(57, 185, 238, 0.98) -#define DO_SIDE_BUTTON_COLOR DO_RGBA(57, 185, 238, 0.9) +#define DO_MENU_BACK_COLOR [UIColor colorWithHexString:LightColor] +#define DO_SIDE_BUTTON_COLOR [UIColor colorWithHexString:LightColor] -#define DO_ALBUM_NAME_TEXT_COLOR DO_RGB(57, 185, 238) +#define DO_ALBUM_NAME_TEXT_COLOR [UIColor colorWithHexString:LightColor] #define DO_ALBUM_COUNT_TEXT_COLOR DO_RGB(247, 200, 142) #define DO_BOTTOM_TEXT_COLOR DO_RGB(255, 255, 255) diff --git a/ImagePicker/DoImagePicker/DoImagePickerController.m b/ImagePicker/DoImagePicker/DoImagePickerController.m index 6c56ff4..a685959 100644 --- a/ImagePicker/DoImagePicker/DoImagePickerController.m +++ b/ImagePicker/DoImagePicker/DoImagePickerController.m @@ -162,16 +162,26 @@ - (IBAction)onSelectPhoto:(id)sender if (_nResultType == DO_PICKER_RESULT_UIIMAGE) { - for (int i = 0; i < _dSelected.count; i++) - [aResult addObject:[ASSETHELPER getImageAtIndex:[aKeys[i] integerValue] type:ASSET_PHOTO_SCREEN_SIZE]]; + for (int i = 0; i < _dSelected.count; i++) { + UIImage *img = [ASSETHELPER getImageAtIndex:[aKeys[i] integerValue] type:ASSET_PHOTO_SCREEN_SIZE]; + if (img) { + [aResult addObject:img]; + } + } } else { - for (int i = 0; i < _dSelected.count; i++) - [aResult addObject:[ASSETHELPER getAssetAtIndex:[aKeys[i] integerValue]]]; + for (int i = 0; i < _dSelected.count; i++) { + ALAsset *img = [ASSETHELPER getAssetAtIndex:[aKeys[i] integerValue]]; + if (img) { + [aResult addObject:img]; + } + } } - [_delegate didSelectPhotosFromDoImagePickerController:self result:aResult]; + if (aResult.count) { + [_delegate didSelectPhotosFromDoImagePickerController:self result:aResult]; + } } - (IBAction)onCancel:(id)sender @@ -282,8 +292,8 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell { DoPhotoCell *cell = (DoPhotoCell *)[_cvPhotoList dequeueReusableCellWithReuseIdentifier:@"DoPhotoCell" forIndexPath:indexPath]; - cell.ivPhoto.image = [ASSETHELPER getImageAtIndex:indexPath.row type:ASSET_PHOTO_THUMBNAIL]; - + cell.ivPhoto.image = [ASSETHELPER getImageAtIndex:indexPath.row type:ASSET_PHOTO_ASPECT_THUMBNAIL]; + if (_dSelected[@(indexPath.row)] == nil) [cell setSelectMode:NO]; else diff --git a/ImagePicker/DoImagePicker/DoImagePickerController.xib b/ImagePicker/DoImagePicker/DoImagePickerController.xib index 8c65772..3a3b320 100644 --- a/ImagePicker/DoImagePicker/DoImagePickerController.xib +++ b/ImagePicker/DoImagePicker/DoImagePickerController.xib @@ -1,7 +1,7 @@ - + - + @@ -94,7 +94,7 @@