FUIBarcodeScanner
public protocol FUIBarcodeScanner: FUISearchBarcodeScanner
Protocol to interact with a Barcode Scanner.
The Scanner
protocol provides methods to start an user interface that automatically scans for 1D and 2D codes.
To find them and therefore retrieve the scanned result it uses the device’s camera.
You retrieve a Scanner instance through ScannerFactory().createScanner(ScanMode)
or
ScannerFactory().createScanner(Set<String>)
.
The Scanner’s scanCode(UIViewController)
method is called from an UIViewController
to start the UI for scanning a code.
The ScannerDelegate
is used to retrieve the respective ScanResult
. You have to register yourself on this delegate and also
implement the delegate protocol in order to retrieve and process the ScanResult
.
The following example depicts the intended Scanner API usage:
// In your UIViewController, when a button is clicked
// you add the Scanner UI to your UIView container:
@IBAction func buttonPressed(sender: AnyObject) {
scanner?.scanCode(uiView)
}
// Implement the didReceiveScanResult of the ScannerDelegate Protocol.
func didReceiveScanResult(scanResult: ScanResult?){
guard let result = scanResult else {
// if the result is nil you can handle this here.
return
}
// do something useful with the scan result.
}
-
The delegate object. The delegate has to conform to the
ScannerDelegate
protocol to receive theScanResult
.Declaration
Swift
weak var delegate:FUIBarcodeScannerDelegate?