Skip to content

Commit 3de0bb1

Browse files
committed
新增allowCameraLocation属性,默认为YES,置为NO时不会在照相时定位
1 parent 6abe3e1 commit 3de0bb1

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@
8787

8888
/// Default is YES, if set NO, user can't picking image.
8989
/// 默认为YES,如果设置为NO,用户将不能选择发送图片
90-
@property(nonatomic, assign) BOOL allowPickingImage;
90+
@property (nonatomic, assign) BOOL allowPickingImage;
9191

9292
/// Default is YES, if set NO, user can't take picture.
9393
/// 默认为YES,如果设置为NO, 用户将不能拍摄照片
94-
@property(nonatomic, assign) BOOL allowTakePicture;
94+
@property (nonatomic, assign) BOOL allowTakePicture;
95+
@property (nonatomic, assign) BOOL allowCameraLocation;
9596

9697
/// Default is YES, if set NO, user can't take video.
9798
/// 默认为YES,如果设置为NO, 用户将不能拍摄视频

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ - (void)configDefaultSetting {
273273
self.allowPreview = YES;
274274
self.statusBarStyle = UIStatusBarStyleLightContent;
275275
self.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
276+
self.allowCameraLocation = YES;
276277

277278
self.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
278279
[self configDefaultBtnTitle];

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -650,18 +650,20 @@ - (void)takePhoto {
650650
// 调用相机
651651
- (void)pushImagePickerController {
652652
// 提前定位
653-
__weak typeof(self) weakSelf = self;
654-
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
655-
__strong typeof(weakSelf) strongSelf = weakSelf;
656-
strongSelf.location = [locations firstObject];
657-
} failureBlock:^(NSError *error) {
658-
__strong typeof(weakSelf) strongSelf = weakSelf;
659-
strongSelf.location = nil;
660-
}];
653+
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
654+
if (tzImagePickerVc.allowCameraLocation) {
655+
__weak typeof(self) weakSelf = self;
656+
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
657+
__strong typeof(weakSelf) strongSelf = weakSelf;
658+
strongSelf.location = [locations firstObject];
659+
} failureBlock:^(NSError *error) {
660+
__strong typeof(weakSelf) strongSelf = weakSelf;
661+
strongSelf.location = nil;
662+
}];
663+
}
661664

662665
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
663666
if ([UIImagePickerController isSourceTypeAvailable: sourceType]) {
664-
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
665667
self.imagePickerVc.sourceType = sourceType;
666668
NSMutableArray *mediaTypes = [NSMutableArray array];
667669
if (tzImagePickerVc.allowTakePicture) {

0 commit comments

Comments
 (0)