Commit 1b577725 authored by banchichen's avatar banchichen

新增allowTakePicture属性,可隐藏拍照按钮

parent 56769d31
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
/// 默认为YES,如果设置为NO,用户将不能选择发送图片 /// 默认为YES,如果设置为NO,用户将不能选择发送图片
@property(nonatomic, assign) BOOL allowPickingImage; @property(nonatomic, assign) BOOL allowPickingImage;
/// Default is YES.if set NO, user can't take picture.
/// 默认为YES,如果设置为NO,拍照按钮将隐藏,用户将不能在选择器中拍照
@property(nonatomic, assign) BOOL allowTakePicture;
/// The photos user have selected /// The photos user have selected
/// 用户选中过的图片数组 /// 用户选中过的图片数组
@property (nonatomic, strong) NSMutableArray *selectedAssets; @property (nonatomic, strong) NSMutableArray *selectedAssets;
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
self.allowPickingOriginalPhoto = YES; self.allowPickingOriginalPhoto = YES;
self.allowPickingVideo = YES; self.allowPickingVideo = YES;
self.allowPickingImage = YES; self.allowPickingImage = YES;
self.allowTakePicture = YES;
self.timeout = 15; self.timeout = 15;
self.photoWidth = 828.0; self.photoWidth = 828.0;
self.photoPreviewMaxWidth = 540; self.photoPreviewMaxWidth = 540;
......
...@@ -109,7 +109,9 @@ static CGSize AssetGridThumbnailSize; ...@@ -109,7 +109,9 @@ static CGSize AssetGridThumbnailSize;
_collectionView.alwaysBounceHorizontal = NO; _collectionView.alwaysBounceHorizontal = NO;
if (iOS7Later) _collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 2); if (iOS7Later) _collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 2);
_collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, -2); _collectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, -2);
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"]) && tzImagePickerVc.allowTakePicture ) {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 4) / 4) * self.view.tz_width); _collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 4) / 4) * self.view.tz_width);
} else { } else {
_collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 3) / 4) * self.view.tz_width); _collectionView.contentSize = CGSizeMake(self.view.tz_width, ((_model.count + 3) / 4) * self.view.tz_width);
...@@ -287,7 +289,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -287,7 +289,7 @@ static CGSize AssetGridThumbnailSize;
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) { if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowPickingImage) { if (tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowTakePicture) {
return _models.count + 1; return _models.count + 1;
} }
} }
...@@ -442,7 +444,7 @@ static CGSize AssetGridThumbnailSize; ...@@ -442,7 +444,7 @@ static CGSize AssetGridThumbnailSize;
NSInteger item = _models.count - 1; NSInteger item = _models.count - 1;
if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) { if ([_model.name isEqualToString:@"相机胶卷"] || [_model.name isEqualToString:@"Camera Roll"] || [_model.name isEqualToString:@"所有照片"] ) {
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController; TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.allowPickingImage) { if (tzImagePickerVc.allowPickingImage && tzImagePickerVc.allowTakePicture) {
item += 1; item += 1;
} }
} }
......
...@@ -123,7 +123,8 @@ ...@@ -123,7 +123,8 @@
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self]; TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self];
imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto; imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
imagePickerVc.selectedAssets = _selectedAssets; // optional, 可选的 imagePickerVc.selectedAssets = _selectedAssets; // optional, 可选的
// imagePickerVc.allowTakePicture = NO; // 隐藏拍照按钮
// You can get the photos by block, the same as by delegate. // You can get the photos by block, the same as by delegate.
// 你可以通过block或者代理,来得到用户选择的照片. // 你可以通过block或者代理,来得到用户选择的照片.
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
......
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