Commit a567b512 authored by tanzhen's avatar tanzhen

加入拍照功能;优化显示效果,可全局显示已选中的图片,切换相册亦可,设置selectedAssets即可显示上次已选中的图片。

parent 55864229
......@@ -18,7 +18,7 @@ typedef enum : NSUInteger {
@class TZAssetModel;
@interface TZAssetCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIButton *selectPhotoButton;
@property (weak, nonatomic) UIButton *selectPhotoButton;
@property (nonatomic, strong) TZAssetModel *model;
@property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL);
@property (nonatomic, assign) TZAssetCellType type;
......@@ -31,5 +31,13 @@ typedef enum : NSUInteger {
@interface TZAlbumCell : UITableViewCell
@property (nonatomic, strong) TZAlbumModel *model;
@property (weak, nonatomic) UIButton *selectedCountButton;
@end
@interface TZAssetCameraCell : UICollectionViewCell
@property (nonatomic, strong) UIImageView *imageView;
@end
\ No newline at end of file
......@@ -169,11 +169,18 @@
[[TZImageManager manager] getPostImageWithAlbumModel:model completion:^(UIImage *postImage) {
self.posterImageView.image = postImage;
}];
if (model.selectedCount) {
self.selectedCountButton.hidden = NO;
[self.selectedCountButton setTitle:[NSString stringWithFormat:@"%zd",model.selectedCount] forState:UIControlStateNormal];
} else {
self.selectedCountButton.hidden = YES;
}
}
/// For fitting iOS6
- (void)layoutSubviews {
if (iOS7Later) [super layoutSubviews];
_selectedCountButton.frame = CGRectMake(self.tz_width - 24 - 30, 23, 24, 24);
}
- (void)layoutSublayersOfLayer:(CALayer *)layer {
......@@ -219,4 +226,42 @@
return _arrowImageView;
}
- (UIButton *)selectedCountButton {
if (_selectedCountButton == nil) {
UIButton *selectedCountButton = [[UIButton alloc] init];
selectedCountButton.layer.cornerRadius = 12;
selectedCountButton.clipsToBounds = YES;
selectedCountButton.backgroundColor = [UIColor redColor];
[selectedCountButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
selectedCountButton.titleLabel.font = [UIFont systemFontOfSize:15];
[self.contentView addSubview:selectedCountButton];
_selectedCountButton = selectedCountButton;
}
return _selectedCountButton;
}
@end
@implementation TZAssetCameraCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
_imageView = [[UIImageView alloc] init];
_imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
_imageView.contentMode = UIViewContentModeScaleAspectFill;
[self addSubview:_imageView];
self.clipsToBounds = YES;
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
_imageView.frame = self.bounds;
}
@end
......@@ -39,4 +39,7 @@ typedef enum : NSUInteger {
@property (nonatomic, assign) NSInteger count; ///< Count of photos the album contain
@property (nonatomic, strong) id result; ///< PHFetchResult<PHAsset> or ALAssetsGroup<ALAsset>
@property (nonatomic, strong) NSArray *models;
@property (nonatomic, strong) NSArray *selectedModels;
@property (nonatomic, assign) NSUInteger selectedCount;
@end
\ No newline at end of file
......@@ -7,6 +7,7 @@
//
#import "TZAssetModel.h"
#import "TZImageManager.h"
@implementation TZAssetModel
......@@ -30,5 +31,36 @@
@implementation TZAlbumModel
- (void)setResult:(id)result {
_result = result;
BOOL allowPickingImage = [[[NSUserDefaults standardUserDefaults] objectForKey:@"tz_allowPickingImage"] isEqualToString:@"1"];
BOOL allowPickingVideo = [[[NSUserDefaults standardUserDefaults] objectForKey:@"tz_allowPickingVideo"] isEqualToString:@"1"];
[[TZImageManager manager] getAssetsFromFetchResult:result allowPickingVideo:allowPickingVideo allowPickingImage:allowPickingImage completion:^(NSArray<TZAssetModel *> *models) {
_models = models;
if (_selectedModels) {
[self checkSelectedModels];
}
}];
}
- (void)setSelectedModels:(NSArray *)selectedModels {
_selectedModels = selectedModels;
if (_models) {
[self checkSelectedModels];
}
}
- (void)checkSelectedModels {
self.selectedCount = 0;
NSMutableArray *selectedAssets = [NSMutableArray array];
for (TZAssetModel *model in _selectedModels) {
[selectedAssets addObject:model.asset];
}
for (TZAssetModel *model in _models) {
if ([selectedAssets containsObject:model.asset]) {
self.selectedCount ++;
}
}
}
@end
\ No newline at end of file
......@@ -54,8 +54,6 @@
PHAssetMediaTypeVideo];
option.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:nil];
for (PHAssetCollection *collection in smartAlbums) {
if ([collection.localizedTitle isEqualToString:@"Camera Roll"] || [collection.localizedTitle isEqualToString:@"相机胶卷"]) {
......
......@@ -16,6 +16,7 @@
*/
#import <UIKit/UIKit.h>
#import "TZAssetModel.h"
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
......@@ -50,20 +51,30 @@
/// 默认为YES,如果设置为NO,用户将不能选择发送图片
@property(nonatomic, assign) BOOL allowPickingImage;
/// The photos user have selected
/// 用户选中过的图片数组
@property (nonatomic, strong) NSArray *selectedAssets;
@property (nonatomic, strong) NSMutableArray<TZAssetModel *> *selectedModels;
- (void)showAlertWithTitle:(NSString *)title;
- (void)showProgressHUD;
- (void)hideProgressHUD;
@property (nonatomic, assign) BOOL isSelectOriginalPhoto;
/// Appearance / 外观颜色
@property (nonatomic, strong) UIColor *oKButtonTitleColorNormal;
@property (nonatomic, strong) UIColor *oKButtonTitleColorDisabled;
// The picker should dismiss itself; when it dismissed these handle will be called.
// The second array will be a empty array if user not picking original photo.
// If isOriginalPhoto is YES, user picked the original photo.
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的handle
// 如果用户没有选择发送原图,第二个数组将是空数组
@property (nonatomic, copy) void (^didFinishPickingPhotosHandle)(NSArray<UIImage *> *photos,NSArray *assets);
@property (nonatomic, copy) void (^didFinishPickingPhotosWithInfosHandle)(NSArray<UIImage *> *photos,NSArray *assets,NSArray<NSDictionary *> *infos);
// 如果isSelectOriginalPhoto为YES,表明用户选择了原图
// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
@property (nonatomic, copy) void (^didFinishPickingPhotosHandle)(NSArray<UIImage *> *photos,NSArray *assets,BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^didFinishPickingPhotosWithInfosHandle)(NSArray<UIImage *> *photos,NSArray *assets,BOOL isSelectOriginalPhoto,NSArray<NSDictionary *> *infos);
@property (nonatomic, copy) void (^imagePickerControllerDidCancelHandle)();
// If user picking a video, this handle will be called.
// If system version > iOS8,asset is kind of PHAsset class, else is ALAsset class.
......@@ -79,11 +90,15 @@
@protocol TZImagePickerControllerDelegate <NSObject>
@optional
// The picker should dismiss itself; when it dismissed these handle will be called.
// Assets will be a empty array if user not picking original photo.
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的回调
// 如果用户没有选择发送原图,Assets将是空数组
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets;
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets infos:(NSArray<NSDictionary *> *)infos;
// If isOriginalPhoto is YES, user picked the original photo.
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的handle
// 如果isSelectOriginalPhoto为YES,表明用户选择了原图
// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto;
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos;
- (void)imagePickerControllerDidCancel:(TZImagePickerController *)picker;
// If user picking a video, this callback will be called.
// If system version > iOS8,asset is kind of PHAsset class, else is ALAsset class.
......
......@@ -78,13 +78,15 @@
if (self) {
self.maxImagesCount = maxImagesCount > 0 ? maxImagesCount : 9; // Default is 9 / 默认最大可选9张图片
self.pickerDelegate = delegate;
self.selectedModels = [NSMutableArray array];
// Allow user picking original photo and video, you also can set No after this method
// 默认准许用户选择原图和视频, 你也可以在这个方法后置为NO
_allowPickingOriginalPhoto = YES;
_allowPickingVideo = YES;
_allowPickingImage = YES;
_timeout = 15;
_photoWidth = 828.0;
self.allowPickingOriginalPhoto = YES;
self.allowPickingVideo = YES;
self.allowPickingImage = YES;
self.timeout = 15;
self.photoWidth = 828.0;
if (![[TZImageManager manager] authorizationStatusAuthorized]) {
_tipLable = [[UILabel alloc] init];
......@@ -188,6 +190,30 @@
}
}
- (void)setSelectedAssets:(NSArray *)selectedAssets {
_selectedAssets = selectedAssets;
_selectedModels = [NSMutableArray array];
for (id asset in selectedAssets) {
TZAssetModel *model = [TZAssetModel modelWithAsset:asset type:TZAssetModelMediaTypePhoto];
model.isSelected = YES;
[_selectedModels addObject:model];
}
}
- (void)setAllowPickingImage:(BOOL)allowPickingImage {
_allowPickingImage = allowPickingImage;
NSString *allowPickingImageStr = _allowPickingImage ? @"1" : @"0";
[[NSUserDefaults standardUserDefaults] setObject:allowPickingImageStr forKey:@"tz_allowPickingImage"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)setAllowPickingVideo:(BOOL)allowPickingVideo {
_allowPickingVideo = allowPickingVideo;
NSString *allowPickingVideoStr = _allowPickingVideo ? @"1" : @"0";
[[NSUserDefaults standardUserDefaults] setObject:allowPickingVideoStr forKey:@"tz_allowPickingVideo"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (iOS7Later) viewController.automaticallyAdjustsScrollViewInsets = NO;
if (_timer) { [_timer invalidate]; _timer = nil;}
......@@ -228,15 +254,24 @@
[super viewWillAppear:animated];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc hideProgressHUD];
if (_albumArr) return;
if (_albumArr) {
for (TZAlbumModel *albumModel in _albumArr) {
albumModel.selectedModels = imagePickerVc.selectedModels;
}
[_tableView reloadData];
} else {
[self configTableView];
}
}
- (void)configTableView {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[[TZImageManager manager] getAllAlbums:imagePickerVc.allowPickingVideo allowPickingImage:imagePickerVc.allowPickingImage completion:^(NSArray<TZAlbumModel *> *models) {
_albumArr = [NSMutableArray arrayWithArray:models];
for (TZAlbumModel *albumModel in _albumArr) {
albumModel.selectedModels = imagePickerVc.selectedModels;
}
if (!_tableView) {
CGFloat top = 44;
if (iOS7Later) top += 20;
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, top, self.view.tz_width, self.view.tz_height - top) style:UITableViewStylePlain];
......@@ -246,6 +281,9 @@
_tableView.delegate = self;
[_tableView registerClass:[TZAlbumCell class] forCellReuseIdentifier:@"TZAlbumCell"];
[self.view addSubview:_tableView];
} else {
[_tableView reloadData];
}
}];
}
......@@ -270,13 +308,20 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TZAlbumCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TZAlbumCell"];
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
cell.selectedCountButton.backgroundColor = imagePickerVc.oKButtonTitleColorNormal;
cell.model = _albumArr[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TZPhotoPickerController *photoPickerVc = [[TZPhotoPickerController alloc] init];
photoPickerVc.model = _albumArr[indexPath.row];
TZAlbumModel *model = _albumArr[indexPath.row];
photoPickerVc.model = model;
[photoPickerVc setBackButtonClickHandle:^(TZAlbumModel *model) {
[_albumArr replaceObjectAtIndex:indexPath.row withObject:model];
}];
[self.navigationController pushViewController:photoPickerVc animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
......
......@@ -12,5 +12,6 @@
@interface TZPhotoPickerController : UIViewController
@property (nonatomic, strong) TZAlbumModel *model;
@property (nonatomic, copy) void (^backButtonClickHandle)(TZAlbumModel *model);
@end
......@@ -11,12 +11,12 @@
@interface TZPhotoPreviewController : UIViewController
@property (nonatomic, strong) NSArray *photoArr; ///< All photos / 所有图片的数组
@property (nonatomic, strong) NSMutableArray *selectedPhotoArr; ///< Current selected photos / 当前选中的图片数组
// @property (nonatomic, strong) NSMutableArray *selectedPhotoArr; ///< Current selected photos / 当前选中的图片数组
@property (nonatomic, assign) NSInteger currentIndex; ///< Index of the photo user click / 用户点击的图片的索引
@property (nonatomic, assign) BOOL isSelectOriginalPhoto; ///< If YES,return original photo / 是否返回原图
/// Return the new selected photos / 返回最新的选中图片数组
@property (nonatomic, copy) void (^returnNewSelectedPhotoArrBlock)(NSMutableArray *newSeletedPhotoArr, BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^okButtonClickBlock)(NSMutableArray *newSeletedPhotoArr, BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^backButtonClickBlock)(BOOL isSelectOriginalPhoto);
@property (nonatomic, copy) void (^okButtonClickBlock)(BOOL isSelectOriginalPhoto);
@end
......@@ -28,18 +28,15 @@
UIButton *_originalPhotoButton;
UILabel *_originalPhotoLable;
}
@property (nonatomic, strong) TZImagePickerController *tzImagePickerVc;
@end
@implementation TZPhotoPreviewController
- (NSMutableArray *)selectedPhotoArr {
if (_selectedPhotoArr == nil) _selectedPhotoArr = [[NSMutableArray alloc] init];
return _selectedPhotoArr;
}
- (void)viewDidLoad {
[super viewDidLoad];
__weak typeof(self) weakSelf = self;
_tzImagePickerVc = (TZImagePickerController *)weakSelf.navigationController;
[self configCollectionView];
[self configCustomNaviBar];
[self configBottomToolBar];
......@@ -85,8 +82,7 @@
_toolBar.backgroundColor = [UIColor colorWithRed:rgb green:rgb blue:rgb alpha:1.0];
_toolBar.alpha = 0.7;
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (imagePickerVc.allowPickingOriginalPhoto) {
if (_tzImagePickerVc.allowPickingOriginalPhoto) {
_originalPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
_originalPhotoButton.frame = CGRectMake(5, 0, 120, 44);
_originalPhotoButton.imageEdgeInsets = UIEdgeInsetsMake(0, -8, 0, 0);
......@@ -115,20 +111,20 @@
_okButton.titleLabel.font = [UIFont systemFontOfSize:16];
[_okButton addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_okButton setTitle:@"确定" forState:UIControlStateNormal];
[_okButton setTitleColor:imagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
[_okButton setTitleColor:_tzImagePickerVc.oKButtonTitleColorNormal forState:UIControlStateNormal];
_numberImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamedFromMyBundle:@"photo_number_icon.png"]];
_numberImageView.backgroundColor = [UIColor clearColor];
_numberImageView.frame = CGRectMake(self.view.tz_width - 56 - 24, 9, 26, 26);
_numberImageView.hidden = _selectedPhotoArr.count <= 0;
_numberImageView.hidden = _tzImagePickerVc.selectedModels.count <= 0;
_numberLable = [[UILabel alloc] init];
_numberLable.frame = _numberImageView.frame;
_numberLable.font = [UIFont systemFontOfSize:16];
_numberLable.textColor = [UIColor whiteColor];
_numberLable.textAlignment = NSTextAlignmentCenter;
_numberLable.text = [NSString stringWithFormat:@"%zd",_selectedPhotoArr.count];
_numberLable.hidden = _selectedPhotoArr.count <= 0;
_numberLable.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
_numberLable.hidden = _tzImagePickerVc.selectedModels.count <= 0;
_numberLable.backgroundColor = [UIColor clearColor];
[_originalPhotoButton addSubview:_originalPhotoLable];
......@@ -164,20 +160,23 @@
TZAssetModel *model = _photoArr[_currentIndex];
if (!selectButton.isSelected) {
// 1. select:check if over the maxImagesCount / 选择照片,检查是否超过了最大个数的限制
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (self.selectedPhotoArr.count >= imagePickerVc.maxImagesCount) {
[imagePickerVc showAlertWithTitle:[NSString stringWithFormat:@"你最多只能选择%zd张照片",imagePickerVc.maxImagesCount]];
if (_tzImagePickerVc.selectedModels.count >= _tzImagePickerVc.maxImagesCount) {
[_tzImagePickerVc showAlertWithTitle:[NSString stringWithFormat:@"你最多只能选择%zd张照片",_tzImagePickerVc.maxImagesCount]];
return;
// 2. if not over the maxImagesCount / 如果没有超过最大个数限制
} else {
[self.selectedPhotoArr addObject:model];
[_tzImagePickerVc.selectedModels addObject:model];
if (model.type == TZAssetModelMediaTypeVideo) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
[imagePickerVc showAlertWithTitle:@"多选状态下选择视频,默认将视频当图片发送"];
[_tzImagePickerVc showAlertWithTitle:@"多选状态下选择视频,默认将视频当图片发送"];
}
}
} else {
[self.selectedPhotoArr removeObject:model];
NSArray *selectedModels = [NSArray arrayWithArray:self.tzImagePickerVc.selectedModels];
for (TZAssetModel *model_item in selectedModels) {
if ([model.asset isEqual:model_item.asset]) {
[self.tzImagePickerVc.selectedModels removeObject:model_item];
}
}
}
model.isSelected = !selectButton.isSelected;
[self refreshNaviBarAndBottomBarState];
......@@ -189,18 +188,18 @@
- (void)back {
[self.navigationController popViewControllerAnimated:YES];
if (self.returnNewSelectedPhotoArrBlock) {
self.returnNewSelectedPhotoArrBlock(self.selectedPhotoArr,_isSelectOriginalPhoto);
if (self.backButtonClickBlock) {
self.backButtonClickBlock(_isSelectOriginalPhoto);
}
}
- (void)okButtonClick {
if (_selectedPhotoArr.count == 0) {
if (_tzImagePickerVc.selectedModels.count == 0) {
TZAssetModel *model = _photoArr[_currentIndex];
[_selectedPhotoArr addObject:model];
[_tzImagePickerVc.selectedModels addObject:model];
}
if (self.okButtonClickBlock) {
self.okButtonClickBlock(self.selectedPhotoArr,_isSelectOriginalPhoto);
self.okButtonClickBlock(_isSelectOriginalPhoto);
}
}
......@@ -218,10 +217,7 @@
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint offSet = scrollView.contentOffset;
_currentIndex = offSet.x / self.view.tz_width;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
_currentIndex = (offSet.x + (self.view.tz_width * 0.5)) / self.view.tz_width;
[self refreshNaviBarAndBottomBarState];
}
......@@ -254,9 +250,9 @@
- (void)refreshNaviBarAndBottomBarState {
TZAssetModel *model = _photoArr[_currentIndex];
_selectButton.selected = model.isSelected;
_numberLable.text = [NSString stringWithFormat:@"%zd",_selectedPhotoArr.count];
_numberImageView.hidden = (_selectedPhotoArr.count <= 0 || _isHideNaviBar);
_numberLable.hidden = (_selectedPhotoArr.count <= 0 || _isHideNaviBar);
_numberLable.text = [NSString stringWithFormat:@"%zd",_tzImagePickerVc.selectedModels.count];
_numberImageView.hidden = (_tzImagePickerVc.selectedModels.count <= 0 || _isHideNaviBar);
_numberLable.hidden = (_tzImagePickerVc.selectedModels.count <= 0 || _isHideNaviBar);
_originalPhotoButton.selected = _isSelectOriginalPhoto;
_originalPhotoLable.hidden = !_originalPhotoButton.isSelected;
......
......@@ -73,10 +73,11 @@
- (IBAction)pickPhotoButtonClick:(UIButton *)sender {
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self];
imagePickerVc.selectedAssets = _selectedAssets; // optional, 可选的
// You can get the photos by block, the same as by delegate.
// 你可以通过block或者代理,来得到用户选择的照片.
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets) {
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
}];
......@@ -105,8 +106,9 @@
/// User finish picking photo,if assets are not empty, user picking original photo.
/// 用户选择好了图片,如果assets非空,则用户选择了原图。
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray *)photos sourceAssets:(NSArray *)assets{
[_selectedPhotos addObjectsFromArray:photos];
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto {
_selectedPhotos = [NSMutableArray arrayWithArray:photos];
_selectedAssets = [NSMutableArray arrayWithArray:assets];
[_collectionView reloadData];
_collectionView.contentSize = CGSizeMake(0, ((_selectedPhotos.count + 2) / 3 ) * (_margin + _itemWH));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment