Commit cb0afa65a38527898d1cfa3fec1d29b63d0847ea
1 parent
596912b5
no message
Showing
12 changed files
with
430 additions
and
117 deletions
CNLiveLoginModule.podspec
CNLiveLoginModule/Assets/CNLiveLoginModule.xcassets/mine_back_black_b.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "idiom" : "universal", | |
| 9 | + "filename" : "mine_back_black_b@2x.png", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "idiom" : "universal", | |
| 14 | + "filename" : "mine_back_black_b@3x.png", | |
| 15 | + "scale" : "3x" | |
| 16 | + } | |
| 17 | + ], | |
| 18 | + "info" : { | |
| 19 | + "version" : 1, | |
| 20 | + "author" : "xcode" | |
| 21 | + } | |
| 22 | +} | |
| 0 | 23 | \ No newline at end of file | ... | ... |
CNLiveLoginModule/Assets/CNLiveLoginModule.xcassets/mine_back_black_b.imageset/mine_back_black_b@2x.png
0 → 100644
1.49 KB
CNLiveLoginModule/Assets/CNLiveLoginModule.xcassets/mine_back_black_b.imageset/mine_back_black_b@3x.png
0 → 100644
1.79 KB
CNLiveLoginModule/Classes/Controller/CNLiveCompleteInfoController.m
| ... | ... | @@ -12,26 +12,33 @@ |
| 12 | 12 | #import "QMUIKit.h" |
| 13 | 13 | #import "YYKit.h" |
| 14 | 14 | |
| 15 | +#import "CNLiveLoginNavigationBar.h" | |
| 15 | 16 | #import "CNLiveCompleteInfoView.h" |
| 16 | 17 | |
| 17 | -@interface CNLiveCompleteInfoController()<CNLiveCompleteInfoViewDelegate> | |
| 18 | +@interface CNLiveCompleteInfoController()<CNLiveCompleteInfoViewDelegate,CNLiveLoginNavigationBarDelegate> | |
| 18 | 19 | @property (nonatomic, strong) CNLiveCompleteInfoView *infoView; |
| 20 | +@property (nonatomic, strong) CNLiveLoginNavigationBar *navigationBar; | |
| 19 | 21 | |
| 20 | 22 | @end |
| 21 | 23 | |
| 22 | 24 | @implementation CNLiveCompleteInfoController |
| 25 | +#pragma mark - 生命周期 | |
| 26 | +- (void)viewWillAppear:(BOOL)animated{ | |
| 27 | + [super viewWillAppear:animated]; | |
| 28 | + self.navigationController.navigationBarHidden = YES; | |
| 29 | +} | |
| 23 | 30 | |
| 24 | 31 | - (void)viewDidLoad { |
| 25 | 32 | [super viewDidLoad]; |
| 26 | 33 | // Do any additional setup after loading the view. |
| 27 | 34 | self.automaticallyAdjustsScrollViewInsets = NO; |
| 28 | 35 | self.view.backgroundColor = [UIColor whiteColor]; |
| 29 | - self.title = @"完善信息"; | |
| 30 | 36 | [self createUI]; |
| 31 | 37 | |
| 32 | 38 | } |
| 33 | 39 | |
| 34 | 40 | - (void)createUI{ |
| 41 | + [self.view addSubview:self.navigationBar]; | |
| 35 | 42 | [self.view addSubview:self.infoView]; |
| 36 | 43 | } |
| 37 | 44 | |
| ... | ... | @@ -60,28 +67,38 @@ |
| 60 | 67 | */ |
| 61 | 68 | |
| 62 | 69 | #pragma mark - 懒加载 |
| 70 | +- (CNLiveLoginNavigationBar *)navigationBar { | |
| 71 | + if (!_navigationBar) { | |
| 72 | + _navigationBar = [[CNLiveLoginNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)]; | |
| 73 | + _navigationBar.backgroundColor = [UIColor whiteColor]; | |
| 74 | + _navigationBar.delegate = self; | |
| 75 | + _navigationBar.title.text = @"完善信息"; | |
| 76 | + _navigationBar.right = nil; | |
| 77 | + } | |
| 78 | + return _navigationBar; | |
| 79 | +} | |
| 80 | + | |
| 63 | 81 | - (CNLiveCompleteInfoView *)infoView{ |
| 64 | 82 | if(!_infoView){ |
| 65 | - _infoView = [[CNLiveCompleteInfoView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop, self.view.frame.size.width*3/4.0, 250)]; | |
| 83 | + _infoView = [[CNLiveCompleteInfoView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/8.0, NavigationContentTop+40, self.view.frame.size.width*3/4.0, 250)]; | |
| 84 | + _infoView.center = CGPointMake(self.view.center.x, self.view.center.y-50); | |
| 66 | 85 | _infoView.delegate = self; |
| 67 | 86 | } |
| 68 | 87 | return _infoView; |
| 69 | 88 | } |
| 70 | 89 | |
| 71 | -/** | |
| 72 | - * 创建图片 | |
| 73 | - * | |
| 74 | - * @param imageName 图片名字 | |
| 75 | - * @param bundleName 图片所在的bundle名字 | |
| 76 | - * @param targetClass 类和bundle的同级目录 | |
| 77 | - * @return 返回UIImage | |
| 78 | - */ | |
| 79 | -- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{ | |
| 80 | - NSBundle *bundle = [NSBundle bundleForClass:targetClass]; | |
| 81 | - NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; | |
| 82 | - NSBundle *targetBundle = [NSBundle bundleWithURL:url]; | |
| 83 | - UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil]; | |
| 84 | - return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; | |
| 90 | +#pragma mark - CNLiveLoginNavigationBarDelegate | |
| 91 | +- (void)navigationBar:(CNLiveLoginNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | |
| 92 | + if ([actionEvents isEqualToString:@"1"]) { | |
| 93 | + if (self.navigationController.topViewController == self) { | |
| 94 | + [self.navigationController popViewControllerAnimated:YES]; | |
| 95 | + }else{ | |
| 96 | + [self dismissViewControllerAnimated:YES completion:nil]; | |
| 97 | + } | |
| 98 | + | |
| 99 | + }else if ([actionEvents isEqualToString:@"2"]){ | |
| 100 | + | |
| 101 | + } | |
| 85 | 102 | } |
| 86 | 103 | |
| 87 | 104 | @end | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveCompleteInfoView.m
| ... | ... | @@ -13,19 +13,12 @@ |
| 13 | 13 | |
| 14 | 14 | #import "CNUserInfoManager.h" |
| 15 | 15 | |
| 16 | -//#import "UIView+Layout.h" | |
| 17 | -//#import "UIImage+Bundle.h" | |
| 18 | -//#import "XWColorHeader.h" | |
| 19 | -//#import <XWUserCenter/XWUserCenter.h> | |
| 20 | -//#import "XWAlertView.h" | |
| 21 | -//#import "XWAlertController.h" | |
| 16 | +#import <AVFoundation/AVCaptureDevice.h> | |
| 17 | +#import <AVFoundation/AVMediaFormat.h> | |
| 18 | +#import "XFCameraController.h" | |
| 19 | +#import "TZImagePickerController.h" | |
| 22 | 20 | |
| 23 | -//#import "NSString+Validation.h" | |
| 24 | -//#import <ZLPhotoBrowser/ZLPhotoBrowser.h> | |
| 25 | -//#import <ZLPhotoBrowser/ZLCustomCamera.h> | |
| 26 | -//#import "XWLoginNotification.h" | |
| 27 | - | |
| 28 | -@interface CNLiveCompleteInfoView()<UITextFieldDelegate>{ | |
| 21 | +@interface CNLiveCompleteInfoView()<UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,TZImagePickerControllerDelegate,QMUIAlertControllerDelegate>{ | |
| 29 | 22 | UIImage *_image; |
| 30 | 23 | } |
| 31 | 24 | |
| ... | ... | @@ -55,8 +48,8 @@ static const NSInteger timeValue = 1.5; |
| 55 | 48 | head.layer.cornerRadius = 40; |
| 56 | 49 | head.layer.masksToBounds = YES; |
| 57 | 50 | head.adjustsImageWhenHighlighted = NO; |
| 58 | - UIImage *image1 = [self xw_getImageName:@"login_camera" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 59 | - [head setImage:image1 forState:UIControlStateNormal]; | |
| 51 | + UIImage *image = [self xw_getImageName:@"login_camera" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 52 | + [head setImage:image forState:UIControlStateNormal]; | |
| 60 | 53 | [head addTarget:self action:@selector(headDidClicked:) forControlEvents:UIControlEventTouchUpInside]; |
| 61 | 54 | [self addSubview:head]; |
| 62 | 55 | self.head = head; |
| ... | ... | @@ -149,92 +142,85 @@ static const NSInteger timeValue = 1.5; |
| 149 | 142 | #pragma mark - Action |
| 150 | 143 | - (void)headDidClicked:(UIButton *)btn{ |
| 151 | 144 | btn.userInteractionEnabled = NO; |
| 152 | -// NSArray *optionArray = @[@"从相册中选择",@"相机"]; | |
| 153 | -// XWActionSheetView *sheetView = [[XWActionSheetView alloc] initWithOptions:optionArray select:^(NSInteger index) { | |
| 154 | -// NSLog(@"%@",optionArray[index]); | |
| 155 | -// if(index == 0){ | |
| 156 | -// // 相册 | |
| 157 | -// ZLPhotoActionSheet *ac = [[ZLPhotoActionSheet alloc] init]; | |
| 158 | -// // 相册参数配置,configuration有默认值,可直接使用并对其属性进行修改 | |
| 159 | -// ac.configuration.maxSelectCount = 1; | |
| 160 | -// ac.configuration.maxPreviewCount = 10; | |
| 161 | -// //如调用的方法无sender参数,则该参数必传 | |
| 162 | -// ac.sender = (UIViewController *)self.delegate; | |
| 163 | -// __weak typeof(self) weakSelf = self; | |
| 164 | -// [ac setSelectImageBlock:^(NSArray<UIImage *> * _Nonnull images, NSArray<PHAsset *> * _Nonnull assets, BOOL isOriginal) { | |
| 165 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 166 | -// if(!strongSelf) return; | |
| 167 | -// strongSelf->_image = images[0]; | |
| 168 | -// [strongSelf.head setImage:images[0] forState:UIControlStateNormal]; | |
| 169 | -// | |
| 170 | -// }]; | |
| 171 | -// [ac showPreviewAnimated:YES]; | |
| 172 | -// | |
| 173 | -// }else if (index == 1){ | |
| 174 | -// // 相机 | |
| 175 | -// ZLCustomCamera *camera = [[ZLCustomCamera alloc] init]; | |
| 176 | -// camera.allowTakePhoto = YES; | |
| 177 | -// __weak typeof(self) weakSelf = self; | |
| 178 | -// camera.doneBlock = ^(UIImage *image, NSURL *videoUrl) { | |
| 179 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 180 | -// if(!strongSelf) return; | |
| 181 | -// strongSelf->_image = image; | |
| 182 | -// [strongSelf.head setImage:image forState:UIControlStateNormal]; | |
| 183 | -// | |
| 184 | -// }; | |
| 185 | -// [(UIViewController *)self.delegate showDetailViewController:camera sender:nil]; | |
| 186 | -// } | |
| 187 | -// btn.userInteractionEnabled = YES; | |
| 188 | -// | |
| 189 | -// } cancel:^{ | |
| 190 | -// btn.userInteractionEnabled = YES; | |
| 191 | -// NSLog(@"取消"); | |
| 192 | -// | |
| 193 | -// }]; | |
| 194 | -// [sheetView show]; | |
| 195 | -// XWAlertController *alertController = [XWAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:XWAlertControllerStyleActionSheet]; | |
| 196 | -// alertController.needDialogBlur = NO; | |
| 197 | -// XWAlertAction *action1 = [XWAlertAction actionWithTitle:@"从相册中选择" style:XWAlertActionStyleDefault handler:^(XWAlertAction * _Nonnull action) { | |
| 198 | -// ZLPhotoActionSheet *ac = [[ZLPhotoActionSheet alloc] init]; | |
| 199 | -// // 相册参数配置,configuration有默认值,可直接使用并对其属性进行修改 | |
| 200 | -// ac.configuration.maxSelectCount = 1; | |
| 201 | -// ac.configuration.maxPreviewCount = 10; | |
| 202 | -// //如调用的方法无sender参数,则该参数必传 | |
| 203 | -// ac.sender = (UIViewController *)self.delegate; | |
| 204 | -// __weak typeof(self) weakSelf = self; | |
| 205 | -// [ac setSelectImageBlock:^(NSArray<UIImage *> * _Nonnull images, NSArray<PHAsset *> * _Nonnull assets, BOOL isOriginal) { | |
| 206 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 207 | -// if(!strongSelf) return; | |
| 208 | -// strongSelf->_image = images[0]; | |
| 209 | -// [strongSelf.head setImage:images[0] forState:UIControlStateNormal]; | |
| 210 | -// | |
| 211 | -// }]; | |
| 212 | -// [ac showPreviewAnimated:YES]; | |
| 213 | -// btn.userInteractionEnabled = YES; | |
| 214 | -// }]; | |
| 215 | -// XWAlertAction *action2 = [XWAlertAction actionWithTitle:@"相机" style:XWAlertActionStyleDefault handler:^(XWAlertAction * _Nonnull action) { | |
| 216 | -// // 相机 | |
| 217 | -// ZLCustomCamera *camera = [[ZLCustomCamera alloc] init]; | |
| 218 | -// camera.allowTakePhoto = YES; | |
| 219 | -// __weak typeof(self) weakSelf = self; | |
| 220 | -// camera.doneBlock = ^(UIImage *image, NSURL *videoUrl) { | |
| 221 | -// __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 222 | -// if(!strongSelf) return; | |
| 223 | -// strongSelf->_image = image; | |
| 224 | -// [strongSelf.head setImage:image forState:UIControlStateNormal]; | |
| 225 | -// | |
| 226 | -// }; | |
| 227 | -// [(UIViewController *)weakSelf.delegate presentViewController:camera animated:YES completion:nil]; | |
| 228 | -// btn.userInteractionEnabled = YES; | |
| 229 | -// }]; | |
| 230 | -// | |
| 231 | -// XWAlertAction *action3 = [XWAlertAction actionWithTitle:@"取消" style:XWAlertActionStyleCancel handler:^(XWAlertAction * _Nonnull action) { | |
| 232 | -// btn.userInteractionEnabled = YES; | |
| 233 | -// }]; | |
| 234 | -// [alertController addAction:action1]; | |
| 235 | -// [alertController addAction:action3]; // 取消按钮一定排在最底部 | |
| 236 | -// [alertController addAction:action2]; | |
| 237 | -// [(UIViewController *)self.delegate presentViewController:alertController animated:YES completion:^{}]; | |
| 145 | + __weak typeof(self) weakSelf = self; | |
| 146 | + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"拍照" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 147 | + btn.userInteractionEnabled = YES; | |
| 148 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 149 | + if(!strongSelf) return ; | |
| 150 | + __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 151 | + [strongSelf getAVAuthorizationStatus:^{ | |
| 152 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 153 | + if(!strongSelf) return ; | |
| 154 | + XFCameraController *cameraController = [[XFCameraController alloc] init]; | |
| 155 | + cameraController.isCanShootVideo = NO; | |
| 156 | + cameraController.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 157 | + __weak XFCameraController *weakCameraController = cameraController; | |
| 158 | + __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 159 | + cameraController.takePhotosCompletionBlock = ^(UIImage *image, NSError *error) { | |
| 160 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 161 | + if(!strongSelf) return ; | |
| 162 | + strongSelf->_image = image; | |
| 163 | + [strongSelf.head setImage:image forState:UIControlStateNormal]; | |
| 164 | + | |
| 165 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 166 | + [weakCameraController dismissViewControllerAnimated:YES completion:nil]; | |
| 167 | + }); | |
| 168 | + }; | |
| 169 | + [(UIViewController *)self.delegate presentViewController:cameraController animated:YES completion:nil]; | |
| 170 | + }]; | |
| 171 | + | |
| 172 | + }]; | |
| 173 | + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"从手机相册中选择" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 174 | + btn.userInteractionEnabled = YES; | |
| 175 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 176 | + if(!strongSelf) return ; | |
| 177 | + __strong typeof(strongSelf) weakSelf = strongSelf; | |
| 178 | + [strongSelf getPHAuthorizationStatus:^{ | |
| 179 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 180 | + if(!strongSelf) return ; | |
| 181 | + TZImagePickerController *picker = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:strongSelf]; | |
| 182 | + picker.modalPresentationStyle = UIModalPresentationFullScreen; | |
| 183 | + picker.allowPickingVideo = NO; | |
| 184 | + picker.allowPreview = NO; | |
| 185 | + __weak typeof(strongSelf) weakSelf = strongSelf; | |
| 186 | + [picker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) { | |
| 187 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 188 | + if(!strongSelf) return ; | |
| 189 | + strongSelf->_image = [photos firstObject]; | |
| 190 | + [strongSelf.head setImage:[photos firstObject] forState:UIControlStateNormal]; | |
| 191 | + }]; | |
| 192 | + [(UIViewController *)strongSelf.delegate presentViewController:picker animated:YES completion:nil]; | |
| 193 | + }]; | |
| 194 | + | |
| 195 | + }]; | |
| 196 | + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) { | |
| 197 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 198 | + if(!strongSelf) return ; | |
| 199 | + | |
| 200 | + }]; | |
| 201 | + | |
| 202 | + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet]; | |
| 203 | + alertController.delegate = self; | |
| 204 | + [alertController addAction:action1]; | |
| 205 | + [alertController addAction:action2]; | |
| 206 | + [alertController addAction:cancel]; | |
| 207 | + | |
| 208 | + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 209 | + | |
| 210 | + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0]; | |
| 211 | + | |
| 212 | + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes]; | |
| 213 | + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0]; | |
| 214 | + | |
| 215 | + action1.buttonAttributes = titleAttributs; | |
| 216 | + action2.buttonAttributes = titleAttributs; | |
| 217 | + cancel.buttonAttributes = cancelAttributs; | |
| 218 | + | |
| 219 | + [alertController showWithAnimated:YES]; | |
| 220 | + | |
| 221 | +} | |
| 222 | +- (void)didHideAlertController:(QMUIAlertController *)alertController{ | |
| 223 | + self.head.userInteractionEnabled = YES; | |
| 238 | 224 | |
| 239 | 225 | } |
| 240 | 226 | - (void)nextDidClicked:(UIButton *)btn{ |
| ... | ... | @@ -291,4 +277,92 @@ static const NSInteger timeValue = 1.5; |
| 291 | 277 | return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; |
| 292 | 278 | } |
| 293 | 279 | |
| 280 | +- (void)getAVAuthorizationStatus:(void (^)(void))block{ | |
| 281 | + AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; | |
| 282 | + if (device) { | |
| 283 | + AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; | |
| 284 | + switch (status) { | |
| 285 | + case AVAuthorizationStatusNotDetermined: { | |
| 286 | + [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { | |
| 287 | + if (granted) { | |
| 288 | + dispatch_sync(dispatch_get_main_queue(), ^{ | |
| 289 | + block(); | |
| 290 | + }); | |
| 291 | + NSLog(@"用户第一次同意了访问相机权限 - - %@", [NSThread currentThread]); | |
| 292 | + } else { | |
| 293 | + NSLog(@"用户第一次拒绝了访问相机权限 - - %@", [NSThread currentThread]); | |
| 294 | + } | |
| 295 | + }]; | |
| 296 | + break; | |
| 297 | + } | |
| 298 | + case AVAuthorizationStatusAuthorized: { | |
| 299 | + block(); | |
| 300 | + break; | |
| 301 | + } | |
| 302 | + case AVAuthorizationStatusDenied: { | |
| 303 | + NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; | |
| 304 | + NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"]; | |
| 305 | + if (app_Name == nil) { | |
| 306 | + app_Name = [infoDict objectForKey:@"CFBundleName"]; | |
| 307 | + } | |
| 308 | + NSString *messageString = [NSString stringWithFormat:@"请在iPhone的\"设置 - 隐私 - 相机\"选项中,允许%@访问你的相机", app_Name]; | |
| 309 | + UIAlertController *alertC = [UIAlertController alertControllerWithTitle:nil message:messageString preferredStyle:(UIAlertControllerStyleAlert)]; | |
| 310 | + UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"好" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) { | |
| 311 | + | |
| 312 | + }]; | |
| 313 | + | |
| 314 | + [alertC addAction:alertA]; | |
| 315 | + [(UIViewController *)self.delegate presentViewController:alertC animated:YES completion:nil]; | |
| 316 | + break; | |
| 317 | + } | |
| 318 | + case AVAuthorizationStatusRestricted: { | |
| 319 | + NSLog(@"因为系统原因, 无法访问相册"); | |
| 320 | + break; | |
| 321 | + } | |
| 322 | + | |
| 323 | + default: | |
| 324 | + break; | |
| 325 | + } | |
| 326 | + return; | |
| 327 | + } | |
| 328 | + [QMUITips showError:@"未检测到您的摄像头" inView:self.superview hideAfterDelay:timeValue]; | |
| 329 | +} | |
| 330 | + | |
| 331 | +- (void)getPHAuthorizationStatus:(void (^)(void))block{ | |
| 332 | + // 1.获取当前App的相册授权状态 | |
| 333 | + PHAuthorizationStatus authorizationStatus = [PHPhotoLibrary authorizationStatus]; | |
| 334 | + | |
| 335 | + // 2.判断授权状态 | |
| 336 | + if (authorizationStatus == PHAuthorizationStatusAuthorized) { | |
| 337 | + // 2.1 如果已经授权, 保存图片(调用步骤2的方法) | |
| 338 | + block(); | |
| 339 | + | |
| 340 | + } else if (authorizationStatus == PHAuthorizationStatusNotDetermined) { // 如果没决定, 弹出指示框, 让用户选择 | |
| 341 | + [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { | |
| 342 | + // 如果用户选择授权, 则保存图片 | |
| 343 | + if (status == PHAuthorizationStatusAuthorized) { | |
| 344 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 345 | + block(); | |
| 346 | + }); | |
| 347 | + } | |
| 348 | + }]; | |
| 349 | + | |
| 350 | + } else { | |
| 351 | + NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; | |
| 352 | + NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"]; | |
| 353 | + if (app_Name == nil) { | |
| 354 | + app_Name = [infoDict objectForKey:@"CFBundleName"]; | |
| 355 | + } | |
| 356 | + NSString *messageString = [NSString stringWithFormat:@"请在iPhone的\"设置 - 隐私 - 相机\"选项中,允许%@访问你的相册", app_Name]; | |
| 357 | + UIAlertController *alertC = [UIAlertController alertControllerWithTitle:nil message:messageString preferredStyle:(UIAlertControllerStyleAlert)]; | |
| 358 | + UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"好" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) { | |
| 359 | + | |
| 360 | + }]; | |
| 361 | + | |
| 362 | + [alertC addAction:alertA]; | |
| 363 | + [(UIViewController *)self.delegate presentViewController:alertC animated:YES completion:nil]; | |
| 364 | + } | |
| 365 | +} | |
| 366 | + | |
| 367 | + | |
| 294 | 368 | @end | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginNavigationBar.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveLoginNavigationBar.m | |
| 3 | +// CNLiveLoginModule | |
| 4 | +// | |
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | |
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | +@class CNLiveLoginNavigationBar; | |
| 13 | + | |
| 14 | +@protocol CNLiveLoginNavigationBarDelegate <NSObject> | |
| 15 | +- (void)navigationBar:(CNLiveLoginNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents; | |
| 16 | + | |
| 17 | +@end | |
| 18 | + | |
| 19 | +@interface CNLiveLoginNavigationBar : UIView | |
| 20 | +@property (nonatomic, weak) id<CNLiveLoginNavigationBarDelegate> delegate; | |
| 21 | +@property (nonatomic, strong) UIView *navView; | |
| 22 | +@property (nonatomic, strong) UIButton *left; | |
| 23 | +@property (nonatomic, strong) UILabel *title; | |
| 24 | +@property (nonatomic, strong, nullable) UIButton *right; | |
| 25 | + | |
| 26 | + | |
| 27 | +@end | |
| 28 | + | |
| 29 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginNavigationBar.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveLoginNavigationBar.m | |
| 3 | +// CNLiveLoginModule | |
| 4 | +// | |
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | |
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNLiveLoginNavigationBar.h" | |
| 10 | +#import "QMUIKit.h" | |
| 11 | + | |
| 12 | +@interface CNLiveLoginNavigationBar () | |
| 13 | + | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@implementation CNLiveLoginNavigationBar | |
| 17 | +static const NSInteger margin = 15; | |
| 18 | + | |
| 19 | +- (instancetype)initWithFrame:(CGRect)frame{ | |
| 20 | + self = [super initWithFrame:frame]; | |
| 21 | + if(self){ | |
| 22 | + self.userInteractionEnabled = YES; | |
| 23 | + self.backgroundColor = [UIColor clearColor]; | |
| 24 | + [self createSubViews]; | |
| 25 | + } | |
| 26 | + return self; | |
| 27 | +} | |
| 28 | + | |
| 29 | +- (void)dealloc { | |
| 30 | + NSLog(@"CNLiveSettingNavigationBar -- dealloc"); | |
| 31 | +} | |
| 32 | + | |
| 33 | +- (void)createSubViews { | |
| 34 | + [self addSubview:self.navView]; | |
| 35 | + [self addSubview:self.left]; | |
| 36 | + [self addSubview:self.title]; | |
| 37 | + [self addSubview:self.right]; | |
| 38 | +} | |
| 39 | + | |
| 40 | +/* | |
| 41 | + // Only override drawRect: if you perform custom drawing. | |
| 42 | + // An empty implementation adversely affects performance during animation. | |
| 43 | + - (void)drawRect:(CGRect)rect { | |
| 44 | + // Drawing code | |
| 45 | + } | |
| 46 | + */ | |
| 47 | + | |
| 48 | +#pragma mark - 懒加载 | |
| 49 | +- (UIView *)navView { | |
| 50 | + if (!_navView) { | |
| 51 | + _navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, NavigationContentTop)]; | |
| 52 | + _navView.backgroundColor = [UIColor clearColor]; | |
| 53 | + } | |
| 54 | + return _navView; | |
| 55 | +} | |
| 56 | + | |
| 57 | +- (UIButton *)left { | |
| 58 | + if (!_left) { | |
| 59 | + _left= [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 60 | + _left.adjustsImageWhenHighlighted = NO; | |
| 61 | + _left.frame = CGRectMake(margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight); | |
| 62 | + UIImage *image = [self xw_getImageName:@"mine_back_black_b" bundleName:@"CNLiveLoginModule" targetClass:[self class]]; | |
| 63 | + [_left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; | |
| 64 | + _left.titleLabel.font = [UIFont systemFontOfSize:15]; | |
| 65 | + [_left setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; | |
| 66 | + [_left addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside]; | |
| 67 | + } | |
| 68 | + return _left; | |
| 69 | +} | |
| 70 | + | |
| 71 | +- (UILabel *)title { | |
| 72 | + if (!_title) { | |
| 73 | + _title = [[UILabel alloc] initWithFrame:CGRectMake(margin+NavigationBarHeight, StatusBarHeight, SCREEN_WIDTH-2*(margin+NavigationBarHeight), NavigationBarHeight)]; | |
| 74 | + [_title setFont:[UIFont systemFontOfSize:18]]; | |
| 75 | + _title.textColor = [UIColor blackColor]; | |
| 76 | + _title.textAlignment = NSTextAlignmentCenter; | |
| 77 | + } | |
| 78 | + return _title; | |
| 79 | +} | |
| 80 | + | |
| 81 | +- (UIButton *)right { | |
| 82 | + if (!_right) { | |
| 83 | + _right = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 84 | + _right.frame = CGRectMake(SCREEN_WIDTH-NavigationBarHeight-margin, StatusBarHeight, NavigationBarHeight, NavigationBarHeight); | |
| 85 | + [_right setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight]; | |
| 86 | + _right.adjustsImageWhenHighlighted = NO; | |
| 87 | + _right.titleLabel.font = [UIFont systemFontOfSize:15]; | |
| 88 | + [_right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 89 | + [_right addTarget:self action:@selector(rightDidClicked:) forControlEvents:UIControlEventTouchUpInside]; | |
| 90 | + } | |
| 91 | + return _right; | |
| 92 | +} | |
| 93 | + | |
| 94 | +#pragma mark - 响应方法 | |
| 95 | +- (void)goBack{ | |
| 96 | + if (self.delegate && [self.delegate respondsToSelector:@selector(navigationBar:actionEvents:)]) { | |
| 97 | + [self.delegate navigationBar:self actionEvents:@"1"]; | |
| 98 | + } | |
| 99 | +} | |
| 100 | +- (void)rightDidClicked:(UIButton *)btn{ | |
| 101 | + if (self.delegate && [self.delegate respondsToSelector:@selector(navigationBar:actionEvents:)]) { | |
| 102 | + [self.delegate navigationBar:self actionEvents:@"2"]; | |
| 103 | + } | |
| 104 | +} | |
| 105 | + | |
| 106 | +/** | |
| 107 | + * 创建图片 | |
| 108 | + * | |
| 109 | + * @param imageName 图片名字 | |
| 110 | + * @param bundleName 图片所在的bundle名字 | |
| 111 | + * @param targetClass 类和bundle的同级目录 | |
| 112 | + * @return 返回UIImage | |
| 113 | + */ | |
| 114 | +- (UIImage *)xw_getImageName:(NSString *)imageName bundleName:(NSString *)bundleName targetClass:(Class)targetClass{ | |
| 115 | + NSBundle *bundle = [NSBundle bundleForClass:targetClass]; | |
| 116 | + NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"]; | |
| 117 | + NSBundle *targetBundle = [NSBundle bundleWithURL:url]; | |
| 118 | + UIImage *image = [UIImage imageNamed:imageName inBundle:targetBundle compatibleWithTraitCollection:nil]; | |
| 119 | + return image?image:[UIImage imageNamed:imageName inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil]; | |
| 120 | + | |
| 121 | +} | |
| 122 | + | |
| 123 | +@end | ... | ... |
CNLiveLoginModule/Classes/View/CNLiveLoginView.m
| ... | ... | @@ -331,6 +331,11 @@ static const NSInteger timeValue = 1.5; |
| 331 | 331 | if(!strongSelf) return; |
| 332 | 332 | [QMUITips hideAllToastInView:strongSelf.superview animated:YES]; |
| 333 | 333 | [QMUITips showError:[errorDic objectForKey:@"errorMessage"] inView:strongSelf.superview hideAfterDelay:timeValue]; |
| 334 | + // YES 新用户 NO 老用户 | |
| 335 | + BOOL isNewUser = YES; | |
| 336 | + if (self.delegate && [self.delegate respondsToSelector:@selector(loginSuccess:isNewUser:result:)]) { | |
| 337 | + [self.delegate loginSuccess:self isNewUser:isNewUser result:nil]; | |
| 338 | + } | |
| 334 | 339 | }]; |
| 335 | 340 | } |
| 336 | 341 | ... | ... |
Example/CNLiveLoginModule.xcodeproj/project.pbxproj
| ... | ... | @@ -369,34 +369,54 @@ |
| 369 | 369 | inputPaths = ( |
| 370 | 370 | "${PODS_ROOT}/Target Support Files/Pods-CNLiveLoginModule_Example/Pods-CNLiveLoginModule_Example-frameworks.sh", |
| 371 | 371 | "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", |
| 372 | + "${BUILT_PRODUCTS_DIR}/CNLiveAVCamera/CNLiveAVCamera.framework", | |
| 373 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseKit/CNLiveBaseKit.framework", | |
| 374 | + "${BUILT_PRODUCTS_DIR}/CNLiveBaseTools/CNLiveBaseTools.framework", | |
| 372 | 375 | "${BUILT_PRODUCTS_DIR}/CNLiveBeeHive/CNLiveBeeHive.framework", |
| 376 | + "${BUILT_PRODUCTS_DIR}/CNLiveBusinessTools/CNLiveBusinessTools.framework", | |
| 373 | 377 | "${BUILT_PRODUCTS_DIR}/CNLiveChooseCountry/CNLiveChooseCountry.framework", |
| 378 | + "${BUILT_PRODUCTS_DIR}/CNLiveCommonCategory/CNLiveCommonCategory.framework", | |
| 374 | 379 | "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework", |
| 380 | + "${BUILT_PRODUCTS_DIR}/CNLiveImagePickerController/CNLiveImagePickerController.framework", | |
| 375 | 381 | "${BUILT_PRODUCTS_DIR}/CNLiveManager/CNLiveManager.framework", |
| 376 | 382 | "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework", |
| 377 | 383 | "${BUILT_PRODUCTS_DIR}/CNLiveTripartiteManagement/CNLiveTripartiteManagement.framework", |
| 384 | + "${BUILT_PRODUCTS_DIR}/CNLiveUploadManager/CNLiveUploadManager.framework", | |
| 378 | 385 | "${BUILT_PRODUCTS_DIR}/CNLiveUserAgreementManager/CNLiveUserAgreementManager.framework", |
| 379 | 386 | "${BUILT_PRODUCTS_DIR}/CNLiveUserManagement/CNLiveUserManagement.framework", |
| 387 | + "${BUILT_PRODUCTS_DIR}/HappyDNS/HappyDNS.framework", | |
| 380 | 388 | "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework", |
| 381 | 389 | "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", |
| 382 | 390 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", |
| 391 | + "${BUILT_PRODUCTS_DIR}/Qiniu/Qiniu.framework", | |
| 392 | + "${BUILT_PRODUCTS_DIR}/SDAutoLayout/SDAutoLayout.framework", | |
| 383 | 393 | "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", |
| 384 | 394 | "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", |
| 385 | 395 | ); |
| 386 | 396 | name = "[CP] Embed Pods Frameworks"; |
| 387 | 397 | outputPaths = ( |
| 388 | 398 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", |
| 399 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveAVCamera.framework", | |
| 400 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseKit.framework", | |
| 401 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBaseTools.framework", | |
| 389 | 402 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBeeHive.framework", |
| 403 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveBusinessTools.framework", | |
| 390 | 404 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveChooseCountry.framework", |
| 405 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveCommonCategory.framework", | |
| 391 | 406 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework", |
| 407 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveImagePickerController.framework", | |
| 392 | 408 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveManager.framework", |
| 393 | 409 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework", |
| 394 | 410 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveTripartiteManagement.framework", |
| 411 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUploadManager.framework", | |
| 395 | 412 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserAgreementManager.framework", |
| 396 | 413 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveUserManagement.framework", |
| 414 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HappyDNS.framework", | |
| 397 | 415 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework", |
| 398 | 416 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", |
| 399 | 417 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", |
| 418 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Qiniu.framework", | |
| 419 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDAutoLayout.framework", | |
| 400 | 420 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", |
| 401 | 421 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", |
| 402 | 422 | ); | ... | ... |
Example/CNLiveLoginModule/CNLiveLoginModule-Info.plist
| ... | ... | @@ -2,6 +2,19 @@ |
| 2 | 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 3 | 3 | <plist version="1.0"> |
| 4 | 4 | <dict> |
| 5 | + <key>NSAppTransportSecurity</key> | |
| 6 | + <dict> | |
| 7 | + <key>NSAllowsArbitraryLoads</key> | |
| 8 | + <true/> | |
| 9 | + </dict> | |
| 10 | + <key>NSCameraUsageDescription</key> | |
| 11 | + <string>App需要您的同意,才能访问相机</string> | |
| 12 | + <key>NSMicrophoneUsageDescription</key> | |
| 13 | + <string>App需要您的同意,才能访问麦克风</string> | |
| 14 | + <key>NSPhotoLibraryAddUsageDescription</key> | |
| 15 | + <string>App需要您的同意,才能访问相册</string> | |
| 16 | + <key>NSPhotoLibraryUsageDescription</key> | |
| 17 | + <string>App需要您的同意,才能访问相册</string> | |
| 5 | 18 | <key>CFBundleDevelopmentRegion</key> |
| 6 | 19 | <string>en</string> |
| 7 | 20 | <key>CFBundleDisplayName</key> | ... | ... |
Example/Podfile
| ... | ... | @@ -7,6 +7,10 @@ platform :ios, '9.0' |
| 7 | 7 | target 'CNLiveLoginModule_Example' do |
| 8 | 8 | pod 'CNLiveLoginModule', :path => '../' |
| 9 | 9 | |
| 10 | + #依赖三方私有库,如果里面有.a的时候加上这个 | |
| 11 | + pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {} | |
| 12 | + end | |
| 13 | + | |
| 10 | 14 | target 'CNLiveLoginModule_Tests' do |
| 11 | 15 | inherit! :search_paths |
| 12 | 16 | ... | ... |