Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

分离出定位功能 #1606

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions TZImagePickerController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/banchichen/TZImagePickerController.git", :tag => "3.8.1" }
s.requires_arc = true
s.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
s.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"

s.subspec 'Basic' do |b|
b.resources = "TZImagePickerController/TZImagePickerController/*.{png,bundle}"
b.source_files = "TZImagePickerController/TZImagePickerController/*.{h,m}"
end

s.subspec 'Location' do |l|
l.source_files = 'TZImagePickerController/Location/*.{h,m}'
end

s.frameworks = "Photos", "PhotosUI"
end
18 changes: 8 additions & 10 deletions TZImagePickerController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 901CC3F921CB757500C55443 /* TZImageRequestOperation.m */; };
901F2295215CABD600F604ED /* FLAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 901F2291215CABD600F604ED /* FLAnimatedImage.m */; };
901F2296215CABD600F604ED /* FLAnimatedImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 901F2293215CABD600F604ED /* FLAnimatedImageView.m */; };
902938D81EE2D02C000F2F8F /* TZLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 902938D71EE2D02C000F2F8F /* TZLocationManager.m */; };
9038D5911C3974F0007DE549 /* TZTestCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9038D5901C3974F0007DE549 /* TZTestCell.m */; };
903996931F447604005E77C2 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 903996921F447604005E77C2 /* Photos.framework */; };
90A74B85203287C200D84C2A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 90A74B83203287C200D84C2A /* Localizable.strings */; };
Expand All @@ -60,7 +59,6 @@
9F763A601FA072E500D9E526 /* TZProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DD0502A1DF659ED0057C78D /* TZProgressView.m */; };
9F763A621FA072E500D9E526 /* TZImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 90CE84AD1C3A89EF003D0779 /* TZImageManager.m */; };
9F763A641FA072E500D9E526 /* TZImageCropManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DC84D091DF5358500A107A9 /* TZImageCropManager.m */; };
9F763A661FA072E500D9E526 /* TZLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 902938D71EE2D02C000F2F8F /* TZLocationManager.m */; };
9F763A6A1FA072E500D9E526 /* NSBundle+TZImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D5358CC1D64600F00928CC6 /* NSBundle+TZImagePicker.m */; };
9F763A6B1FA0731E00D9E526 /* TZImagePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 900EEFF61C2BBF9500EA709B /* TZImagePickerController.h */; settings = {ATTRIBUTES = (Public, ); }; };
9F763A6C1FA0733100D9E526 /* TZAssetModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 900EF00D1C2C0B1100EA709B /* TZAssetModel.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -75,7 +73,6 @@
9F763A751FA0741D00D9E526 /* TZProgressView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DD050291DF659ED0057C78D /* TZProgressView.h */; };
9F763A761FA0741D00D9E526 /* TZImageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 90CE84AC1C3A89EF003D0779 /* TZImageManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
9F763A771FA0741D00D9E526 /* TZImageCropManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6DC84D081DF5358500A107A9 /* TZImageCropManager.h */; };
9F763A781FA0741D00D9E526 /* TZLocationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 902938D61EE2D02C000F2F8F /* TZLocationManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
B606A9C4265FD53200F5493E /* TZVideoCropController.m in Sources */ = {isa = PBXBuildFile; fileRef = B606A9C2265FD53200F5493E /* TZVideoCropController.m */; };
B606A9CE265FD5F700F5493E /* TZVideoPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 90CE84B61C3BABB6003D0779 /* TZVideoPlayerController.m */; };
B662C36F2662914D006A672A /* TZVideoEditedPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B662C36E2662914D006A672A /* TZVideoEditedPreviewController.m */; };
Expand Down Expand Up @@ -180,8 +177,6 @@
901F2291215CABD600F604ED /* FLAnimatedImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImage.m; sourceTree = "<group>"; };
901F2292215CABD600F604ED /* FLAnimatedImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLAnimatedImageView.h; sourceTree = "<group>"; };
901F2293215CABD600F604ED /* FLAnimatedImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLAnimatedImageView.m; sourceTree = "<group>"; };
902938D61EE2D02C000F2F8F /* TZLocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZLocationManager.h; sourceTree = "<group>"; };
902938D71EE2D02C000F2F8F /* TZLocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZLocationManager.m; sourceTree = "<group>"; };
9038D58F1C3974F0007DE549 /* TZTestCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TZTestCell.h; sourceTree = "<group>"; };
9038D5901C3974F0007DE549 /* TZTestCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TZTestCell.m; sourceTree = "<group>"; };
903996921F447604005E77C2 /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = System/Library/Frameworks/Photos.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -238,6 +233,13 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5B7A0D4F288691E7002B2603 /* Location */ = {
isa = PBXGroup;
children = (
);
path = Location;
sourceTree = "<group>";
};
6DC358641CC8BAE300898D29 /* Resources */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -272,6 +274,7 @@
900E657E1C2BB8D5003D9A9E /* TZImagePickerController */ = {
isa = PBXGroup;
children = (
5B7A0D4F288691E7002B2603 /* Location */,
901F228F215CABD600F604ED /* FLAnimatedImage */,
900EEFF51C2BBF7600EA709B /* TZImagePickerController */,
900E65821C2BB8D5003D9A9E /* AppDelegate.h */,
Expand Down Expand Up @@ -355,8 +358,6 @@
901CC3F921CB757500C55443 /* TZImageRequestOperation.m */,
6DC84D081DF5358500A107A9 /* TZImageCropManager.h */,
6DC84D091DF5358500A107A9 /* TZImageCropManager.m */,
902938D61EE2D02C000F2F8F /* TZLocationManager.h */,
902938D71EE2D02C000F2F8F /* TZLocationManager.m */,
9005E2B2257A462E002A8682 /* UIView+TZLayout.h */,
9005E2B1257A462E002A8682 /* UIView+TZLayout.m */,
6D5358CB1D64600F00928CC6 /* NSBundle+TZImagePicker.h */,
Expand Down Expand Up @@ -420,7 +421,6 @@
9F763A741FA0741D00D9E526 /* TZGifPhotoPreviewController.h in Headers */,
9005E2B5257A462E002A8682 /* UIView+TZLayout.h in Headers */,
9F763A761FA0741D00D9E526 /* TZImageManager.h in Headers */,
9F763A781FA0741D00D9E526 /* TZLocationManager.h in Headers */,
9F763A711FA0741D00D9E526 /* TZPhotoPreviewController.h in Headers */,
9F763A721FA0741D00D9E526 /* TZPhotoPreviewCell.h in Headers */,
9F763A701FA0741D00D9E526 /* TZAssetCell.h in Headers */,
Expand Down Expand Up @@ -627,7 +627,6 @@
901CC3FC21CB758500C55443 /* TZImageRequestOperation.m in Sources */,
6D5358CD1D64600F00928CC6 /* NSBundle+TZImagePicker.m in Sources */,
900EEFF81C2BBF9500EA709B /* TZImagePickerController.m in Sources */,
902938D81EE2D02C000F2F8F /* TZLocationManager.m in Sources */,
6DC84D0A1DF5358500A107A9 /* TZImageCropManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -668,7 +667,6 @@
9F763A601FA072E500D9E526 /* TZProgressView.m in Sources */,
9F763A621FA072E500D9E526 /* TZImageManager.m in Sources */,
9F763A641FA072E500D9E526 /* TZImageCropManager.m in Sources */,
9F763A661FA072E500D9E526 /* TZLocationManager.m in Sources */,
9F763A6A1FA072E500D9E526 /* NSBundle+TZImagePicker.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@
#import "TZImageManager.h"
#import "TZVideoPlayerController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import "TZPhotoPreviewController.h"
#import "TZPhotoPreviewCell.h"

#if __has_include("TZLocationManager.h")
#define TZ_HAVE_LOCATION_CODE 1
#import "TZLocationManager.h"
#else
#undef TZ_HAVE_LOCATION_CODE
#endif

#define CURRENT_SYSTEM_VERSION [[UIDevice currentDevice] systemVersion]
#define SYSTEM_VERSION_GREATER_THAN_15 ([CURRENT_SYSTEM_VERSION floatValue] >= 15.0)

Expand Down Expand Up @@ -112,7 +118,10 @@
/// Default is YES, if set NO, user can't take picture.
/// 默认为YES,如果设置为NO, 用户将不能拍摄照片
@property (nonatomic, assign) BOOL allowTakePicture;

#ifdef TZ_HAVE_LOCATION_CODE
@property (nonatomic, assign) BOOL allowCameraLocation;
#endif

/// Default is YES, if set NO, user can't take video.
/// 默认为YES,如果设置为NO, 用户将不能拍摄视频
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ - (void)configDefaultSetting {
self.needFixComposition = NO;
self.statusBarStyle = UIStatusBarStyleLightContent;
self.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
#ifdef TZ_HAVE_LOCATION_CODE
self.allowCameraLocation = YES;
#endif
self.presetName = AVAssetExportPresetMediumQuality;
self.maxCropVideoDuration = 30;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#import "TZImageManager.h"
#import "TZVideoPlayerController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import "TZImageRequestOperation.h"
#import "TZAuthLimitedFooterTipView.h"
Expand Down Expand Up @@ -826,6 +825,7 @@ - (void)addMorePhoto {
- (void)pushImagePickerController {
// 提前定位
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
#ifdef TZ_HAVE_LOCATION_CODE
if (tzImagePickerVc.allowCameraLocation) {
__weak typeof(self) weakSelf = self;
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
Expand All @@ -836,6 +836,7 @@ - (void)pushImagePickerController {
strongSelf.location = nil;
}];
}
#endif

UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: sourceType]) {
Expand Down
5 changes: 3 additions & 2 deletions TZImagePickerController/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#import "TZVideoPlayerController.h"
#import "TZPhotoPreviewController.h"
#import "TZGifPhotoPreviewController.h"
#import "TZLocationManager.h"
#import "TZAssetCell.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import "FLAnimatedImage.h"
Expand Down Expand Up @@ -481,6 +480,7 @@ - (void)takePhoto {

// 调用相机
- (void)pushImagePickerController {
#ifdef TZ_HAVE_LOCATION_CODE
// 提前定位
__weak typeof(self) weakSelf = self;
[[TZLocationManager manager] startLocationWithSuccessBlock:^(NSArray<CLLocation *> *locations) {
Expand All @@ -490,7 +490,8 @@ - (void)pushImagePickerController {
__strong typeof(weakSelf) strongSelf = weakSelf;
strongSelf.location = nil;
}];

#endif

UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
self.imagePickerVc.sourceType = sourceType;
Expand Down