Currently in Objective-C, i use Zbar(http://zbar.sourceforge.net/) to generate & read QR Code. Now, i want to move on Swift development only, is there any 'how to' or library about generate and read QR Code in Swift ?
To scan a QR Code with Google Screen Search, you don't need an app. You can use the following steps to scan a QR Code: Point your camera at the QR Code. Hold down the “Home” button and swipe up to reveal the options at the bottom.
On your compatible Android phone or tablet, open the built-in camera app. Point the camera at the QR code. Tap the banner that appears on your Android phone or tablet. Follow the instructions on the screen to finish signing in.
Android 9 and Android 10 have an in-built QR code reader courtesy of Google Lens. Consumers have to open their camera app and point it at the QR Code and see a URL pop-up.
QR Reader for Android is one best QR code scanner apps for android in 2022. This app has a quick and responsive reading capacity as well, and you can also download it for free. It includes different features as well, such as scanning QR codes in real-time using your Android camera.
Beginning with iOS 7, iOS devices can read QR codes. However, there is no built-in way to generate a QR code. Here's a quick and dirty QR code reader.
First, import AVFoundation
and add AVCaptureMetadataOutputObjectsDelegate
Next, setup the capture session:
func captureQRCode() {
let session = AVCaptureSession()
let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
let input = AVCaptureDeviceInput.deviceInputWithDevice(device, error: nil) as AVCaptureDeviceInput
session.addInput(input)
let output = AVCaptureMetadataOutput()
output.setMetadataObjectsDelegate(self, queue: dispatch_get_main_queue())
session.addOutput(output)
output.metadataObjectTypes = [AVMetadataObjectTypeQRCode]
let previewLayer = AVCaptureVideoPreviewLayer(session: session)
let bounds = self.view.layer.bounds
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
previewLayer.bounds = bounds
previewLayer.position = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds))
self.view.layer.addSublayer(previewLayer)
session.startRunning()
}
Finally, handle the delegate
func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {
for item in metadataObjects {
if let metadataObject = item as? AVMetadataMachineReadableCodeObject {
if metadataObject.type == AVMetadataObjectTypeQRCode {
println("QR Code: \(metadataObject.stringValue)")
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With