diff --git a/FacebookImagePicker.podspec b/FacebookImagePicker.podspec index 5d9aafb..a1ab9ad 100644 --- a/FacebookImagePicker.podspec +++ b/FacebookImagePicker.podspec @@ -14,6 +14,6 @@ Pod::Spec.new do |s| } s.source_files = ['FacebookImagePicker/OL*.{h,m}', 'FacebookImagePicker/UIImageView+FacebookFadeIn.{h,m}'] s.resources = ['FacebookImagePicker/FacebookImagePicker.xcassets', 'FacebookImagePicker/*.xib'] - s.dependency 'FBSDKCoreKit', '~> 4.11.0' - s.dependency 'FBSDKLoginKit', '~> 4.11.0' + s.dependency 'FBSDKCoreKit'#, '~> 4.13.1' + s.dependency 'FBSDKLoginKit'#, '~> 4.13.1' end diff --git a/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked.imageset/Contents.json b/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked.imageset/Contents.json index 165eceb..3582041 100644 --- a/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked.imageset/Contents.json +++ b/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked.imageset/Contents.json @@ -2,13 +2,17 @@ "images" : [ { "idiom" : "universal", - "scale" : "1x", - "filename" : "CTAssetsPickerChecked.png" + "filename" : "CTAssetsPickerChecked.png", + "scale" : "1x" }, { "idiom" : "universal", - "scale" : "2x", - "filename" : "CTAssetsPickerChecked@2x.png" + "filename" : "CTAssetsPickerChecked@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked~iOS6.imageset/Contents.json b/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked~iOS6.imageset/Contents.json index 60d4759..5437154 100644 --- a/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked~iOS6.imageset/Contents.json +++ b/FacebookImagePicker/FacebookImagePicker.xcassets/CTAssetsPickerChecked~iOS6.imageset/Contents.json @@ -2,13 +2,17 @@ "images" : [ { "idiom" : "universal", - "scale" : "1x", - "filename" : "CTAssetsPickerChecked~iOS6.png" + "filename" : "CTAssetsPickerChecked~iOS6.png", + "scale" : "1x" }, { "idiom" : "universal", - "scale" : "2x", - "filename" : "CTAssetsPickerChecked~iOS6@2x.png" + "filename" : "CTAssetsPickerChecked~iOS6@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/FacebookImagePicker/FacebookImagePicker.xcassets/album_placeholder.imageset/Contents.json b/FacebookImagePicker/FacebookImagePicker.xcassets/album_placeholder.imageset/Contents.json index 1a8b4f7..45db923 100644 --- a/FacebookImagePicker/FacebookImagePicker.xcassets/album_placeholder.imageset/Contents.json +++ b/FacebookImagePicker/FacebookImagePicker.xcassets/album_placeholder.imageset/Contents.json @@ -6,8 +6,12 @@ }, { "idiom" : "universal", - "scale" : "2x", - "filename" : "album_placeholder@2x.png" + "filename" : "album_placeholder@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" } ], "info" : { diff --git a/FacebookImagePicker/OLAlbumViewController.h b/FacebookImagePicker/OLAlbumViewController.h index 63a7138..28ee6a8 100644 --- a/FacebookImagePicker/OLAlbumViewController.h +++ b/FacebookImagePicker/OLAlbumViewController.h @@ -11,6 +11,9 @@ @class OLAlbumViewController; @class OLFacebookImage; +@interface OLAlbumCell : UITableViewCell +@end + @protocol OLAlbumViewControllerDelegate - (void)albumViewControllerDoneClicked:(OLAlbumViewController *)albumController; - (void)albumViewController:(OLAlbumViewController *)albumController didFailWithError:(NSError *)error; @@ -23,4 +26,5 @@ @property (nonatomic, weak) id delegate; @property (nonatomic, strong) NSArray/**/ *selected; @property (nonatomic, assign) BOOL shouldDisplayLogoutButton; +@property (nonatomic, assign) BOOL isMultiselectEnabled; @end diff --git a/FacebookImagePicker/OLAlbumViewController.m b/FacebookImagePicker/OLAlbumViewController.m index c5e92f0..6cc7e7b 100644 --- a/FacebookImagePicker/OLAlbumViewController.m +++ b/FacebookImagePicker/OLAlbumViewController.m @@ -17,7 +17,7 @@ static const NSUInteger kAlbumPreviewImageSize = 78; -@interface OLAlbumCell : UITableViewCell +@interface OLAlbumCell () @property (nonatomic, strong) OLFacebookAlbum *album; @end @@ -120,6 +120,11 @@ - (void)viewDidAppear:(BOOL)animated { } } +- (void)setIsMultiselectEnabled:(BOOL)isMultiselectEnabled +{ + _isMultiselectEnabled = isMultiselectEnabled; +} + - (void)setShouldDisplayLogoutButton:(BOOL)shouldDisplayLogoutButton { _shouldDisplayLogoutButton = shouldDisplayLogoutButton; @@ -230,6 +235,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { OLFacebookAlbum *album = [self.albums objectAtIndex:indexPath.row]; self.photoViewController = [[OLPhotoViewController alloc] initWithAlbum:album]; + self.photoViewController.isMultiselectEnabled = self.isMultiselectEnabled; self.photoViewController.selected = self.selected; self.photoViewController.delegate = self; [self.navigationController pushViewController:self.photoViewController animated:YES]; @@ -257,7 +263,10 @@ - (void)photoViewController:(OLPhotoViewController *)photoController didFailWith } - (void)photoViewController:(OLPhotoViewController *)photoController didSelectImage:(OLFacebookImage *)image{ - [self updateSelectedFromPhotoViewController]; + if(self.isMultiselectEnabled) { + [self updateSelectedFromPhotoViewController]; + } + if ([self.delegate respondsToSelector:@selector(albumViewController:didSelectImage:)]){ [self.delegate albumViewController:self didSelectImage:image]; } diff --git a/FacebookImagePicker/OLFacebookImagePickerController.h b/FacebookImagePicker/OLFacebookImagePickerController.h index 5299fcf..c4bd05e 100644 --- a/FacebookImagePicker/OLFacebookImagePickerController.h +++ b/FacebookImagePicker/OLFacebookImagePickerController.h @@ -42,4 +42,6 @@ @property (nonatomic, assign) BOOL shouldDisplayLogoutButton; +@property (nonatomic, assign) BOOL isMultiselectEnabled; + @end diff --git a/FacebookImagePicker/OLFacebookImagePickerController.m b/FacebookImagePicker/OLFacebookImagePickerController.m index 0a4a053..ffea17d 100644 --- a/FacebookImagePicker/OLFacebookImagePickerController.m +++ b/FacebookImagePicker/OLFacebookImagePickerController.m @@ -26,6 +26,7 @@ - (id)init { vc.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonClicked)]; if (self = [super initWithRootViewController:vc]) { _shouldDisplayLogoutButton = YES; + _isMultiselectEnabled = YES; if ([FBSDKAccessToken currentAccessToken]){ [self showAlbumList]; } @@ -68,6 +69,7 @@ - (void)showAlbumList{ OLAlbumViewController *albumController = [[OLAlbumViewController alloc] init]; self.albumVC = albumController; self.albumVC.delegate = self; + self.albumVC.isMultiselectEnabled = self.isMultiselectEnabled; self.albumVC.shouldDisplayLogoutButton = self.shouldDisplayLogoutButton; self.viewControllers = @[albumController]; } @@ -80,6 +82,12 @@ - (NSArray *)selected { return self.albumVC.selected; } +- (void)setIsMultiselectEnabled:(BOOL)isMultiselectEnabled +{ + _isMultiselectEnabled = isMultiselectEnabled; + self.albumVC.isMultiselectEnabled = self.isMultiselectEnabled; +} + - (void)setShouldDisplayLogoutButton:(BOOL)shouldDisplayLogoutButton { _shouldDisplayLogoutButton = shouldDisplayLogoutButton; diff --git a/FacebookImagePicker/OLPhotoViewController.h b/FacebookImagePicker/OLPhotoViewController.h index 7c22dbc..f94733e 100644 --- a/FacebookImagePicker/OLPhotoViewController.h +++ b/FacebookImagePicker/OLPhotoViewController.h @@ -27,5 +27,6 @@ @property (nonatomic, weak) id delegate; @property (nonatomic, strong) NSArray/**/ *selected; +@property (nonatomic, assign) BOOL isMultiselectEnabled; @end diff --git a/FacebookImagePicker/OLPhotoViewController.m b/FacebookImagePicker/OLPhotoViewController.m index df29d6e..7ec14ef 100644 --- a/FacebookImagePicker/OLPhotoViewController.m +++ b/FacebookImagePicker/OLPhotoViewController.m @@ -60,7 +60,7 @@ - (void)viewDidLoad { layout.minimumLineSpacing = 1.0; layout.footerReferenceSize = CGSizeMake(0, 0); self.collectionView.collectionViewLayout = layout; - self.collectionView.allowsMultipleSelection = YES; + self.collectionView.allowsMultipleSelection = self.isMultiselectEnabled; [self.collectionView registerClass:[OLFacebookImagePickerCell class] forCellWithReuseIdentifier:kImagePickerCellReuseIdentifier]; [self.collectionView registerClass:[SupplementaryView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:kSupplementaryViewFooterReuseIdentifier]; @@ -69,6 +69,12 @@ - (void)viewDidLoad { [self loadNextPage]; } +- (void) setIsMultiselectEnabled:(BOOL)isMultiselectEnabled +{ + _isMultiselectEnabled = isMultiselectEnabled; + self.collectionView.allowsMultipleSelection = isMultiselectEnabled; +} + - (NSArray *)selected { NSMutableArray *selectedItems = [[NSMutableArray alloc] init]; NSArray *selectedPaths = self.collectionView.indexPathsForSelectedItems; @@ -204,7 +210,13 @@ -(void) collectionView:(UICollectionView *)collectionView didDeselectItemAtIndex } -(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ - [self updateTitleWithSelectedIndexPaths:collectionView.indexPathsForSelectedItems]; + if(self.isMultiselectEnabled) { + [self updateTitleWithSelectedIndexPaths:collectionView.indexPathsForSelectedItems]; + + } else { + [collectionView deselectItemAtIndexPath:indexPath animated:NO]; + } + if ([self.delegate respondsToSelector:@selector(photoViewController:didSelectImage:)]){ [self.delegate photoViewController:self didSelectImage:[self.photos objectAtIndex:indexPath.item]]; }