Member-only story

Make QRReader app swift

Mr.Javed Multani
2 min readOct 6, 2020

--

Today I am gonna show you how to make attractive and useful QRReader app for iPhone by follow simply some steps.

First import library,

import AVFoundation

Now take one view which you can see scanning are by using camera and set IBOutlet like:

@IBOutlet weak var viewPreview: UIView!

Take one UIButton for perform action start and stop scanning:

@IBOutlet weak var btnStartStop: UIButton!

We need a boolean varible so we take it like:

var isReading: Bool = false

Finally take on UILabel which shows the results/output :

@IBOutlet weak var lblString: UILabel!

Set Delegate for view like:

class ViewController: UIViewController,AVCaptureMetadataOutputObjectsDelegate {

Write this code on ViewDidLoad for initial setup:

viewPreview.layer.cornerRadius = 5;                               btnStartStop.layer.cornerRadius = 5;                               captureSession = nil;        
lblString.text = "Barcode discription...";

We have to write following code on button action:

@IBAction func buttonHandlerStart(_ sender: Any) {…

--

--

Mr.Javed Multani
Mr.Javed Multani

Written by Mr.Javed Multani

Software Engineer | Certified ScrumMaster® (CSM) | UX Researcher | Youtuber | Tech Writer

No responses yet