Commit 70a5802661dc1c8057a579927c5c7268ff973d88
1 parent
f6b4dff6
no message
Showing
2 changed files
with
39 additions
and
42 deletions
CNLiveQrCodeModule/Classes/Controller/CNLiveScanQrCodeController.m
| ... | ... | @@ -185,32 +185,6 @@ static const CGFloat timeValue = 1.5; |
| 185 | 185 | }]; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | -#pragma mark - 选择图片识别二维码 | |
| 189 | -- (void)rightButtonDidClicked:(UIButton *)btn { | |
| 190 | - // 从相册中读取二维码 | |
| 191 | - [obtain establishAuthorizationQRCodeObtainAlbumWithController:nil]; | |
| 192 | - if (obtain.isPHAuthorization == YES) { | |
| 193 | - [self.scanView removeTimer]; | |
| 194 | - } | |
| 195 | - | |
| 196 | - __weak typeof(self) weakSelf = self; | |
| 197 | - [obtain setBlockWithQRCodeObtainAlbumDidCancelImagePickerController:^(SGQRCodeObtain *obtain) { | |
| 198 | - __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 199 | - if(!strongSelf) return ; | |
| 200 | - }]; | |
| 201 | - [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) { | |
| 202 | - __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 203 | - if(!strongSelf) return ; | |
| 204 | - if (result == nil) { | |
| 205 | - NSLog(@"暂未识别出二维码"); | |
| 206 | - [QMUITips showError:@"暂未识别出二维码" inView:strongSelf.view hideAfterDelay:timeValue]; | |
| 207 | - | |
| 208 | - } else { | |
| 209 | - [strongSelf handleResult:result]; | |
| 210 | - } | |
| 211 | - }]; | |
| 212 | -} | |
| 213 | - | |
| 214 | 188 | #pragma mark - 识别二维码后判断处理 |
| 215 | 189 | - (void)handleResult:(NSString *)result{ |
| 216 | 190 | NSLog(@"结果---%@",result); |
| ... | ... | @@ -269,9 +243,36 @@ static const CGFloat timeValue = 1.5; |
| 269 | 243 | |
| 270 | 244 | } |
| 271 | 245 | |
| 246 | +#pragma mark - 选择图片识别二维码 | |
| 272 | 247 | - (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ |
| 273 | 248 | if ([actionEvents isEqualToString:@"1"]) { |
| 274 | 249 | [self goBack]; |
| 250 | + }else if([actionEvents isEqualToString:@"2"]){ | |
| 251 | + _navigationBar.right.userInteractionEnabled = NO; | |
| 252 | + // 从相册中读取二维码 | |
| 253 | + [obtain establishAuthorizationQRCodeObtainAlbumWithController:nil]; | |
| 254 | + if (obtain.isPHAuthorization == YES) { | |
| 255 | + [self.scanView removeTimer]; | |
| 256 | + } | |
| 257 | + | |
| 258 | + __weak typeof(self) weakSelf = self; | |
| 259 | + [obtain setBlockWithQRCodeObtainAlbumDidCancelImagePickerController:^(SGQRCodeObtain *obtain) { | |
| 260 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 261 | + if(!strongSelf) return ; | |
| 262 | + strongSelf.navigationBar.right.userInteractionEnabled = YES; | |
| 263 | + }]; | |
| 264 | + [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) { | |
| 265 | + __strong typeof(weakSelf) strongSelf = weakSelf; | |
| 266 | + if(!strongSelf) return ; | |
| 267 | + strongSelf.navigationBar.right.userInteractionEnabled = YES; | |
| 268 | + if (result == nil) { | |
| 269 | + NSLog(@"暂未识别出二维码"); | |
| 270 | + [QMUITips showError:@"暂未识别出二维码" inView:strongSelf.view hideAfterDelay:timeValue]; | |
| 271 | + | |
| 272 | + } else { | |
| 273 | + [strongSelf handleResult:result]; | |
| 274 | + } | |
| 275 | + }]; | |
| 275 | 276 | } |
| 276 | 277 | } |
| 277 | 278 | #pragma mark - 懒加载 | ... | ... |
Example/CNLiveQrCodeModule.xcodeproj/xcshareddata/xcschemes/CNLiveQrCodeModule-Example.xcscheme
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | <BuildableReference |
| 16 | 16 | BuildableIdentifier = "primary" |
| 17 | 17 | BlueprintIdentifier = "6003F589195388D20070C39A" |
| 18 | - BuildableName = "CNLiveQrCodeModule_Example.app" | |
| 18 | + BuildableName = "二维码模块.app" | |
| 19 | 19 | BlueprintName = "CNLiveQrCodeModule_Example" |
| 20 | 20 | ReferencedContainer = "container:CNLiveQrCodeModule.xcodeproj"> |
| 21 | 21 | </BuildableReference> |
| ... | ... | @@ -27,6 +27,15 @@ |
| 27 | 27 | selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
| 28 | 28 | selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
| 29 | 29 | shouldUseLaunchSchemeArgsEnv = "YES"> |
| 30 | + <MacroExpansion> | |
| 31 | + <BuildableReference | |
| 32 | + BuildableIdentifier = "primary" | |
| 33 | + BlueprintIdentifier = "6003F589195388D20070C39A" | |
| 34 | + BuildableName = "二维码模块.app" | |
| 35 | + BlueprintName = "CNLiveQrCodeModule_Example" | |
| 36 | + ReferencedContainer = "container:CNLiveQrCodeModule.xcodeproj"> | |
| 37 | + </BuildableReference> | |
| 38 | + </MacroExpansion> | |
| 30 | 39 | <Testables> |
| 31 | 40 | <TestableReference |
| 32 | 41 | skipped = "NO"> |
| ... | ... | @@ -39,17 +48,6 @@ |
| 39 | 48 | </BuildableReference> |
| 40 | 49 | </TestableReference> |
| 41 | 50 | </Testables> |
| 42 | - <MacroExpansion> | |
| 43 | - <BuildableReference | |
| 44 | - BuildableIdentifier = "primary" | |
| 45 | - BlueprintIdentifier = "6003F589195388D20070C39A" | |
| 46 | - BuildableName = "CNLiveQrCodeModule_Example.app" | |
| 47 | - BlueprintName = "CNLiveQrCodeModule_Example" | |
| 48 | - ReferencedContainer = "container:CNLiveQrCodeModule.xcodeproj"> | |
| 49 | - </BuildableReference> | |
| 50 | - </MacroExpansion> | |
| 51 | - <AdditionalOptions> | |
| 52 | - </AdditionalOptions> | |
| 53 | 51 | </TestAction> |
| 54 | 52 | <LaunchAction |
| 55 | 53 | buildConfiguration = "Debug" |
| ... | ... | @@ -66,13 +64,11 @@ |
| 66 | 64 | <BuildableReference |
| 67 | 65 | BuildableIdentifier = "primary" |
| 68 | 66 | BlueprintIdentifier = "6003F589195388D20070C39A" |
| 69 | - BuildableName = "CNLiveQrCodeModule_Example.app" | |
| 67 | + BuildableName = "二维码模块.app" | |
| 70 | 68 | BlueprintName = "CNLiveQrCodeModule_Example" |
| 71 | 69 | ReferencedContainer = "container:CNLiveQrCodeModule.xcodeproj"> |
| 72 | 70 | </BuildableReference> |
| 73 | 71 | </BuildableProductRunnable> |
| 74 | - <AdditionalOptions> | |
| 75 | - </AdditionalOptions> | |
| 76 | 72 | </LaunchAction> |
| 77 | 73 | <ProfileAction |
| 78 | 74 | buildConfiguration = "Release" |
| ... | ... | @@ -85,7 +81,7 @@ |
| 85 | 81 | <BuildableReference |
| 86 | 82 | BuildableIdentifier = "primary" |
| 87 | 83 | BlueprintIdentifier = "6003F589195388D20070C39A" |
| 88 | - BuildableName = "CNLiveQrCodeModule_Example.app" | |
| 84 | + BuildableName = "二维码模块.app" | |
| 89 | 85 | BlueprintName = "CNLiveQrCodeModule_Example" |
| 90 | 86 | ReferencedContainer = "container:CNLiveQrCodeModule.xcodeproj"> |
| 91 | 87 | </BuildableReference> | ... | ... |