Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Added a new property for single selection image size. #19

Merged
merged 3 commits into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
*/
@property (nonatomic, readonly) YMSPhotoPickerTheme *theme;

/**
* @brief Use this property to customize the returned item type for single selection. Default value is NO.
*/
@property (nonatomic, assign) BOOL shouldReturnAssetForSingleSelection;
Copy link
Contributor

@yzlai yzlai Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing with @stewwu, we'd agree return Asset is a better behavior.
However, we also want to make this change backward compatible. Thus, how about renaming this new property to shouldReturnImageForSingleSelection with default YES ?


@end

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ - (instancetype)init
if (self) {
self.selectedPhotos = [NSMutableArray array];
self.numberOfPhotoToSelect = 1;
self.shouldReturnAssetForSingleSelection = NO;
}
return self;
}
Expand Down Expand Up @@ -213,6 +214,12 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
if (indexPath.row == 0) {
[self yms_presentCameraCaptureViewWithDelegate:self];
}
else if (self.shouldReturnAssetForSingleSelection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this condition checking under line 223 ?
This would prevent user enable multipleSelection and return Asset/Image at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yzlai Please review my latest commit.

PHFetchResult *fetchResult = self.currentCollectionItem[@"assets"];
PHAsset *asset = fetchResult[indexPath.item-1];
[self.selectedPhotos addObject:asset];
[self finishPickingPhotos:nil];
}
else if (NO == self.allowsMultipleSelection) {

PHFetchResult *fetchResult = self.currentCollectionItem[@"assets"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ - (IBAction)presentPhotoPicker:(id)sender
}
else {
[[YMSPhotoPickerTheme sharedInstance] reset];
[self yms_presentAlbumPhotoViewWithDelegate:self];
YMSPhotoPickerViewController *pickerViewController = [[YMSPhotoPickerViewController alloc] init];
pickerViewController.shouldReturnAssetForSingleSelection = YES;
[self yms_presentCustomAlbumPhotoView:pickerViewController delegate:self];
}
}

Expand Down