Skip to content

Commit f3e8f7a

Browse files
committed
fixed the bug: cannot restart barcode scan session
1 parent b0d40d6 commit f3e8f7a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ios/RCTBarcode/RCTBarcode/RCTBarcode.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ - (void)removeFromSuperview
5252
{
5353
// NSLog(@"removeFromSuperview...");
5454

55-
[self.scanLineTimer invalidate];
56-
self.scanLineTimer = nil;
57-
5855
[self.manager endSession];
5956
[super removeFromSuperview];
6057
}

ios/RCTBarcode/RCTBarcode/RCTBarcodeManager.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ - (id)init {
6161
}
6262

6363
- (void)initializeCaptureSessionInput:(NSString *)type {
64+
65+
NSLog(@"initializeCaptureSessionInput...");
66+
6467
dispatch_async(self.sessionQueue, ^{
6568

6669
[self.session beginConfiguration];
@@ -84,6 +87,9 @@ - (void)initializeCaptureSessionInput:(NSString *)type {
8487

8588

8689
if ([self.session canAddInput:captureDeviceInput]) {
90+
91+
NSLog(@"self.session canAddInput:captureDeviceInput...");
92+
8793
[self.session addInput:captureDeviceInput];
8894

8995
self.videoCaptureDeviceInput = captureDeviceInput;
@@ -107,6 +113,9 @@ - (void)initializeCaptureSessionInput:(NSString *)type {
107113
// NSLog(@"self.metadataOutput = %@", self.metadataOutput);
108114

109115
if(self.metadataOutput == nil) {
116+
117+
NSLog(@"self.metadataOutput = %@", self.metadataOutput);
118+
110119
AVCaptureMetadataOutput *metadataOutput = [[AVCaptureMetadataOutput alloc] init];
111120
self.metadataOutput = metadataOutput;
112121

@@ -171,13 +180,15 @@ - (void)endSession {
171180
[self.session commitConfiguration];
172181
[self.session stopRunning];
173182
[self.barcode.scanLineTimer invalidate];
183+
self.barcode.scanLineTimer = nil;
174184
for(AVCaptureInput *input in self.session.inputs) {
175185
[self.session removeInput:input];
176186
}
177187

178188
for(AVCaptureOutput *output in self.session.outputs) {
179189
[self.session removeOutput:output];
180190
}
191+
self.metadataOutput = nil;
181192
});
182193
}
183194

0 commit comments

Comments
 (0)