Closed purplecofe closed 6 years ago
me too !
You have to keep a reference to the QRCodeReader
and add its previous layer by yourself in your view:
I am seeing this behavior too. sometimes. for now, i was not able to reproduce it reliably.
BUT: I am using the code from the example project to instantiate the QRCodeReaderViewController
from the pod files:
lazy var reader: QRCodeReader = QRCodeReader()
lazy var readerVC: QRCodeReaderViewController = {
let builder = QRCodeReaderViewControllerBuilder {
$0.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObject.ObjectType.qr], captureDevicePosition: .back)
$0.showTorchButton = true
}
return QRCodeReaderViewController(builder: builder)
}()
As far as I understand in this 'standard' ViewController the proposed fix for the behavior is already included, right?
I am using Xcode 9,swift 4 and QRCodeReader 8.0.3 . My test device is a iphone 6s plus running ios 9.3.5.
I see this too, on my iphone SE running ios 11
Me too!
The same problem. An unmodified code, freshly downloaded from here. Cannot reproduce it reliably, but it occurs in about 20% of the app's starts. The app has to be killed to get an other attempt (cancel button will not help).
Tested on iPhone 6s (iOS 11) and iPhone 4s (iOS 9), Xcode 9.1.
Maybe it's coincidence, but it seems it happens mainly when the device is connected to Xcode. Can anyone confirm this observation?
To be sure, the issue occurs when your are using the provided view controller or in the example project with the embedded view?
Is it related to #125?
1) Example project.
2) Hard to say. I'm unable to reproduce it in preview mode. However, if the "modal mode" is stuck in the black screen (black screen with icons and the rectangle), the preview mode works just fine along with it. There is also no info about scanner behavior in #125. Here, the scanner works ok, only the "live view" does not work, so you have to scan it blindly. This state is permanent for the session (cancel button or scanned QR code does not change the situation, only hard restart of the app - the app has to be killed or redeployed).
In QRCodeReader.swift/Sources/QRCodeReaderView.swift I changed line 74 from private weak var reader: QRCodeReader?
to var reader: QRCodeReader?
. Since that change, everything works fine (aka i was not able to reproduce the described behavior anymore).
@Jackhammer42 so the issue came from the fact the reader
var is weak
?
I'll investigate that, because I don't know why it happens.
yes, indeed.
I have the same problem. Did you find a solution?
I'dont know why but when set readerVC in viewDidAppear it's stable. I have done hundreds of tests today and it never happened. Any ideas?
override func viewDidAppear(_ animated: Bool) {
readerVC = {
let builder = QRCodeReaderViewControllerBuilder {
$0.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObject.ObjectType.qr], captureDevicePosition: .back)
$0.showTorchButton = true
}
return QRCodeReaderViewController(builder: builder)
}()
}
@rustydr34m the last release don't fix your issue?
You still have to init the reader in the viewDidAppear
?
@yannickl private weak var reader: QRCodeReader? to private var reader: QRCodeReader? not fix the problem,
But when init the reader in the viewDidAppear (reader still private weak var reader: QRCodeReader?) problem solved for me. But I don't know why.
@yannickl
previewLayer
is initial twice when i debug
If a property marked with the lazy modifier is accessed by multiple threads simultaneously and the property has not yet been initialized, there is no guarantee that the property will be initialized only once.
@ruoyuruoshui thank you for pointing me this point because I was sure it was atomic. I'll investigate that.
Still have this issue any news about this? I would really want to use it!
@vcsabi is the issue still there with the v8.1.0
?
@yannickl Really appreciate your fast response, and yes with the latest version
in iphonex does not work at all
@rustydr34m Did you find any solution ? It's same for me also.
Please provide solution for "Camera is not display, but scan is work, case of custom interface" in Xcode 10.1
Have the same problem
Have the same problem
And me
@yannickl Please provide solution for "Camera is not display, but scan is work, case of custom interface"
update to swift 4 version before is work fine
but update to swift 4 version after is not work
how can i fix it?
source code here https://gist.github.com/purplecofe/c9ea540760a990bf5aeec62b4507bee8
thanks for your help