ScannerViewController
open class ScannerViewController : NibViewController, AVCaptureMetadataOutputObjectsDelegate
A NibViewController
subclass that scans codes using the device’s camera.
This view controller captures codes from the device’s camera.
The code is then passed into the captureAction
closure property.
Note
Being a subclass of aNibViewController
, an associated nib file is required with outlets connected.
-
A closure that is executed upon pressing the help button.
By default, this closure opens the eettings of the device.
Declaration
Swift
open var helpAction: (ScannerViewController, UIButton) -> Void
-
The capture session object.
Declaration
Swift
open var captureSession: AVCaptureSession?
-
The preview layer object of the capture session.
Declaration
Swift
open var previewLayer: AVCaptureVideoPreviewLayer?
-
The capture device input object.
Declaration
Swift
open var deviceInput: AVCaptureDeviceInput?
-
The metadata output object.
Declaration
Swift
open var metadataOutput: AVCaptureMetadataOutput?
-
The metadata output object types.
This defines the acceptable object types of the scanner. By default, this is set to accept QR, EAN-8,EAN-13 (including UPC-A), and PDF417 codes.
Declaration
Swift
open var metadataObjectTypes: [AVMetadataObject.ObjectType]
-
A closure executed upon the capturing of the code.
Declaration
Swift
open var captureAction: ((ScannerViewController, String) -> Void)?
-
Declaration
Swift
override open func setup()
-
Undocumented
Declaration
Swift
override open func viewDidLayoutSubviews()
-
Sets up the help UI components and action.
Declaration
Swift
open func setupHelp()
-
Sets up the capture session components.
Declaration
Swift
open func setupCaptor()
-
Starts the scanning for codes using the device’s camera.
Declaration
Swift
open func startScanning()
-
Stops the scanning for codes.
Declaration
Swift
open func stopScanning()
-
This is exectured when there is a problem encountered when setting up the capture session.
Declaration
Swift
open func scanFailed(with title: String?, message: String?)
Parameters
title
The title for the error encountered.
message
The message for the error encountered.
-
Undocumented
Declaration
Swift
open func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection)