Commit d1212621b3bb57bac56b63de464ed3ef63088fde
1 parent
d5b843aa
no message
Showing
3 changed files
with
33 additions
and
28 deletions
CNLiveQrCodeModule/Classes/Controller/CNLiveMyQrCodeController.m
CNLiveQrCodeModule/Classes/Controller/CNLiveScanQrCodeController.m
| ... | ... | @@ -264,39 +264,45 @@ static const CGFloat timeValue = 1.5; |
| 264 | 264 | __weak typeof(self) weakSelf = self; |
| 265 | 265 | _navigationBar.onClickLeftButton = ^{ |
| 266 | 266 | __strong typeof(weakSelf) strongSelf = weakSelf; |
| 267 | - if(!strongSelf) return ; | |
| 267 | + if(!strongSelf) return; | |
| 268 | 268 | [strongSelf goBack]; |
| 269 | 269 | }; |
| 270 | 270 | _navigationBar.onClickRightButton = ^{ |
| 271 | - _navigationBar.right.userInteractionEnabled = NO; | |
| 272 | - // 从相册中读取二维码 | |
| 273 | - [obtain establishAuthorizationQRCodeObtainAlbumWithController:nil]; | |
| 274 | - if (obtain.isPHAuthorization == YES) { | |
| 275 | - [self.scanView removeTimer]; | |
| 276 | - } | |
| 277 | - | |
| 278 | - __weak typeof(self) weakSelf = self; | |
| 279 | - [obtain setBlockWithQRCodeObtainAlbumDidCancelImagePickerController:^(SGQRCodeObtain *obtain) { | |
| 280 | - __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 281 | - if(!strongSelf) return ; | |
| 282 | - strongSelf.navigationBar.right.userInteractionEnabled = YES; | |
| 283 | - }]; | |
| 284 | - [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) { | |
| 285 | - __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 286 | - if(!strongSelf) return ; | |
| 287 | - strongSelf.navigationBar.right.userInteractionEnabled = YES; | |
| 288 | - if (result == nil) { | |
| 289 | - NSLog(@"暂未识别出二维码"); | |
| 290 | - [QMUITips showError:@"暂未识别出二维码" inView:strongSelf.view hideAfterDelay:timeValue]; | |
| 291 | - | |
| 292 | - } else { | |
| 293 | - [strongSelf handleResult:result]; | |
| 294 | - } | |
| 295 | - }]; | |
| 271 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 272 | + if(!strongSelf) return ; | |
| 273 | + [strongSelf rightButton]; | |
| 296 | 274 | }; |
| 297 | 275 | } |
| 298 | 276 | return _navigationBar; |
| 299 | 277 | } |
| 278 | +- (void)rightButton{ | |
| 279 | + _navigationBar.right.userInteractionEnabled = NO; | |
| 280 | + // 从相册中读取二维码 | |
| 281 | + [obtain establishAuthorizationQRCodeObtainAlbumWithController:nil]; | |
| 282 | + if (obtain.isPHAuthorization == YES) { | |
| 283 | + [self.scanView removeTimer]; | |
| 284 | + } | |
| 285 | + | |
| 286 | + __weak typeof(self) weakSelf = self; | |
| 287 | + [obtain setBlockWithQRCodeObtainAlbumDidCancelImagePickerController:^(SGQRCodeObtain *obtain) { | |
| 288 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 289 | + if(!strongSelf) return ; | |
| 290 | + strongSelf.navigationBar.right.userInteractionEnabled = YES; | |
| 291 | + }]; | |
| 292 | + [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) { | |
| 293 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 294 | + if(!strongSelf) return ; | |
| 295 | + strongSelf.navigationBar.right.userInteractionEnabled = YES; | |
| 296 | + if (result == nil) { | |
| 297 | + NSLog(@"暂未识别出二维码"); | |
| 298 | + [QMUITips showError:@"暂未识别出二维码" inView:strongSelf.view hideAfterDelay:timeValue]; | |
| 299 | + | |
| 300 | + } else { | |
| 301 | + [strongSelf handleResult:result]; | |
| 302 | + } | |
| 303 | + }]; | |
| 304 | + | |
| 305 | +} | |
| 300 | 306 | - (SGQRCodeScanView *)scanView { |
| 301 | 307 | if (!_scanView) { |
| 302 | 308 | _scanView = [[SGQRCodeScanView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; | ... | ... |
Example/CNLiveQrCodeModule/CNLIVEAppDelegate.m
| ... | ... | @@ -63,7 +63,7 @@ |
| 63 | 63 | }]; |
| 64 | 64 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; |
| 65 | 65 | |
| 66 | - CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc] init]; | |
| 66 | + CNLiveMyQrCodeController *vc = [[CNLiveMyQrCodeController alloc] init]; | |
| 67 | 67 | // vc.ID = @"http://www.baidu.com"; |
| 68 | 68 | UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; |
| 69 | 69 | ... | ... |