SBSBarcodePicker Class Reference

Inherits UIViewController.

Instance Methods

(nonnull instancetype) - initWithSettings:
 
(void) - addPropertyObserver:
 
(void) - removePropertyObserver:
 
(BOOL) - isScanning
 
(void) - addWarningsObserver:
 
(void) - removeWarningsObserver:
 
Barcode Decoder Configuration
(void) - applyScanSettings:completionHandler:
 
Barcode Recognition Operation
(void) - startScanning
 
(void) - startScanningInPausedState:
 
(void) - startScanningInPausedState:completionHandler:
 
(void) - stopScanningWithCompletionHandler:
 
(void) - stopScanning
 
(void) - resumeScanning
 
(void) - resumeScanningWithCompletionHandler:
 
(void) - pauseScanning
 
(void) - pauseScanningWithCompletionHandler:
 
Utility
(CGPoint) - convertPointToPickerCoordinates:
 
Camera Selection
(BOOL) - supportsCameraFacing:
 
(BOOL) - changeToCameraFacing:
 
(BOOL) - switchCameraFacing
 
Torch Control
(void) - switchTorchOn:
 
Zoom control
(BOOL) - setRelativeZoom:
 
Parser Instantiation
(nullable SBSParser *) - parserForFormat:error:
 
Generator Instantiation
(nullable SBSBarcodeGenerator *) - barcodeGeneratorForSymbology:error:
 

Properties

UIInterfaceOrientationMask allowedInterfaceOrientations
 
SBSOverlayControlleroverlayController
 
id< SBSScanDelegatescanDelegate
 
id< SBSProcessFrameDelegateprocessFrameDelegate
 
id< SBSLicenseValidationDelegatelicenseValidationDelegate
 
SBSCameraFacingDirection cameraFacingDirection
 
AVCaptureVideoOrientation cameraPreviewOrientation
 
BOOL autoFocusOnTapEnabled
 
BOOL pinchToZoomEnabled
 
id< SBSTextRecognitionDelegatetextRecognitionDelegate
 

Detailed Description

Controls the camera and orchestrates the barcode scanning process.

The barcode picker provides a high-level interface for scanning barcodes on iOS. The class is responsible for initializing and controlling the camera and manages the low-level barcode scanning process. The barcode picker also provides a configurable scan user interface in which recognized barcodes are highlighted.

Example (minimal) usage:

Set up the barcode picker in one of your view controllers:

// Set your app key on the license first.
[SBSLicense setAppKey:kScanditBarcodeScannerAppKey];
// Create the settings used for the picker.
SBSScanSettings *scanSettings = [SBSScanSettings defaultSettings];
// Enable symbologies etc.
[scanSettings setSymbology:SBSSymbologyEAN13 enabled:YES];
// Instantiate the barcode picker
SBSBarcodePicker barcodePicker = [[SBSBarcodePicker alloc] initWithSettings:scanSettings];
// Set a class as the scan delegate to handle events when a barcode is successfully scanned.
barcodePicker.scanDelegate = self;
// Present the barcode picker in some way (for example in a navigation controller)
[self.navigationController pushViewController:barcodePicker animated:YES];
// Start the scanning
[barcodePicker startScanning];
Since
4.7.0

Method Documentation

- (nonnull instancetype) initWithSettings: (nullable SBSScanSettings *)  settings

Initializes the barcode picker with the desired scan settings.

Note that the initial invocation of this method will activate the Scandit Barcode Scanner SDK, after which the device will count towards your device limit.

Make sure to set the app key available from your Scandit account through SBSLicense::setAppKey before you call this initializer.

Since
4.7.0
Parameters
settingsThe scan settings to use. You may pass nil, which is identical to passing a settings instance constructed through defaultSettings (SBSScanSettings).
Returns
The newly constructed barcode picker instance.
- (void) applyScanSettings: (nonnull SBSScanSettings *)  settings
completionHandler: (nullable void(^)(void))  handler 

Change the scan settings of an existing picker instance.

The scan settings are applied asynchronously after this call returns. You may use the completion handler to get notified when the settings have been applied to the picker. All frames processed after the settings have been applied will use the new scan settings.

Parameters
settingsThe new scan settings to apply.
handlerAn optional block that will be invoked when the settings have been applied to the picker. The block will be invoked on an internal picker dispatch queue.
Since
4.7.0
- (void) addPropertyObserver: (nullable id< SBSPropertyObserver >)  observer

Add a observer that gets called whenever a property changes.

This API is experimental. There are no API stability guarantees at this point and this API might change or dissapear in a future release.

Parameters
observerThe observer to add
Since
4.14.0
- (void) removePropertyObserver: (nullable id< SBSPropertyObserver >)  observer

remove a property changed delegate

In case the observer was not registered previously, this call has no effect.

Parameters
observerThe observer to remove
Since
4.14.0
- (void) startScanning

Starts/restarts the camera and the scanning process.

Start or continue scanning barcodes after the creation of the barcode picker or a previous call to pauseScanning, pauseScanning (SBSScanSession), stopScanning or stopScanning (SBSScanSession).

This method is identical to calling [SBSBarcodePicker startScanningInPausedState:NO];

Since
4.7.0
- (void) startScanningInPausedState: (BOOL)  paused

Starts/restarts the camera and potentially the scanning process.

Start or continue scanning barcodes after the creation of the barcode picker or a previous call to pauseScanning, pauseScanning (SBSScanSession), stopScanning or stopScanning (SBSScanSession).

In contrast to resumeScanning, startScanning clears the current barcode scanner session.

Since
4.7.0
Parameters
pausedIf YES the barcode/2D recognition is paused but the streaming of preview images is started. If NO both the barcode/2D recognition and the streaming of preview images are started.
- (void) startScanningInPausedState: (BOOL)  paused
completionHandler: (nullable void(^)(void))  handler 

Starts/restarts the camera and potentially the scanning process.

Start or continue scanning barcodes after the creation of the barcode picker or a previous call to pauseScanning, pauseScanning (SBSScanSession), stopScanning or stopScanning (SBSScanSession).

In contrast to resumeScanning, startScanning clears the current barcode scanner session.

Since
4.12.0
Parameters
pausedIf YES the barcode/2D recognition is paused but the streaming of preview images is started. If NO both the barcode/2D recognition and the streaming of preview images are started.
handlerIf nonnull, the handler is invoked when the camera has completed initialization. The handler is invoked from a picker-internal queue, which may or may not run on the UI thread.
- (void) stopScanningWithCompletionHandler: (nullable void(^)(void))  handler

Stop scanning and the video preview.

This method will stop the scanning and video preview asynchronously. If non-null, the completion handler will be invoked once the preview and the scanning have been stopped.

Parameters
handlerhandler to be invoked when the preview and scanning has been stopped.
Since
4.7.0
- (void) stopScanning

Stop scanning and the video preview.

This method will stop the scanning and video preview asynchronously. If your are restarting the scanning shortly after stopping, use stopScanningWithCompletionHandler: and call startScanning only after the completion handler has been called.

Since
4.7.0
- (void) resumeScanning

Resume scanning codes.

Continue (resume) scanning barcodes after a previous call to pauseScanning, or pauseScanning (SBSScanSession). Calling resumeScanning on a picker that was stopped with stopScanning, will not resume the scanning process.

In contrast to startScanning, resumeScanning does not clear the current barcode scanner session. Thus if you want accumulate the codes, use pauseScanning/resumeScanning, if you want to start from an empty session, use pauseScanning/startScanning.

Since
4.7.0
- (void) resumeScanningWithCompletionHandler: (nullable void(^)(void))  handler

Resume scanning codes.

Continue (resume) scanning barcodes after a previous call to pauseScanning, or pauseScanning (SBSScanSession). Calling resumeScanning on a picker that was stopped with stopScanning, will not resume the scanning process.

In contrast to startScanning, resumeScanning does not clear the current barcode scanner session. Thus if you want accumulate the codes, use pauseScanning/resumeScanning, if you want to start from an empty session, use pauseScanning/startScanning.

Parameters
handlerBlock to be invoked when the scanning has been resumed.
Since
4.16.0
- (void) pauseScanning

Pause scanning but keep preview on.

This method pauses barcode/2D recognition but continues streaming preview images. Use this method if you are interrupting barcode recognition for a short time and want to continue scanning barcodes/2D codes afterwards.

Use resumeScanning to continue scanning barcodes.

Since
4.7.0
- (void) pauseScanningWithCompletionHandler: (nullable void(^)(void))  handler

Pause scanning but keep preview on.

This method pauses barcode/2D recognition but continues streaming preview images. Use this method if you are interrupting barcode recognition for a short time and want to continue scanning barcodes/2D codes afterwards.

Use resumeScanning to continue scanning barcodes.

Parameters
handlerBlock to be invoked when the scanning has been paused.
Since
4.16.0
- (CGPoint) convertPointToPickerCoordinates: (CGPoint)  point

Converts a point of an SBSCode's location into this picker's coordinate system.

The conversion takes the current resolution of the camera feed into consideration which means that if the resolution should change converting a previously retrieved point successfully is no longer possible. A change in resolution happens for example if SBSScanSettings::highDensityModeEnabled is changed or the camera is switched from back to front or vice versa.

Since
4.9.0
Parameters
pointThe point to be converted.
Returns
The point in the picker's coordinate system.
See also
SBSCode::location
- (BOOL) isScanning

Returns YES if scanning is in progress.

Since
1.0.0
Returns
boolean indicating whether scanning is in progress.
- (BOOL) supportsCameraFacing: (SBSCameraFacingDirection facing

Returns whether the specified camera facing direction is supported by the current device.

Since
3.0.0
Parameters
facingThe camera facing direction in question.
Returns
Whether the camera facing direction is supported
- (BOOL) changeToCameraFacing: (SBSCameraFacingDirection facing

Changes to the specified camera facing direction if it is supported.

Since
3.0.0
Parameters
facingThe new camera facing direction
Returns
Whether the change was successful
- (BOOL) switchCameraFacing

Changes to the opposite camera facing if it is supported.

Since
3.0.0
Returns
Whether the change was successful
- (void) switchTorchOn: (BOOL)  on

Switches the torch (if available) on or off programmatically.

There is also a method in the ScanditSDKOverlayController to add a torch icon that the user can click to activate the torch.

Parameters
onYES when the torch should be switched on, NO if the torch should be turned off.

By default the torch switch is off.

Since
2.0.0
- (BOOL) setRelativeZoom: (float)  zoom

Sets the zoom to the given percentage of the maximum analog zoom possible.

Parameters
zoomThe percentage of the max zoom (between 0 and 1)
Returns
Whether setting the zoom was successful

Note that this value might be overwritten by the relative zoom value of the scan settings (SBSScanSettings::relativeZoom), if the scan settings are applied after this method has been called.

Since
4.7.0
- (nullable SBSParser *) parserForFormat: (SBSParserDataFormat)  dataFormat
error: (NSError *_Nullable *_Nullable)  outError 

Instantiates a parser object.

Parameters
dataFormatThe format of the input data for the parser.
outErrorDescribes errors during instantiation of the parser. This out parameter is set to nil on success.
Returns
A parser instance or nil

This method only returns a parser instance if the license used to instantiate the picker includes the usage of the Scandit Parser Library. Otherwise a nil pointer is returned.

Since
5.5.0
- (nullable SBSBarcodeGenerator *) barcodeGeneratorForSymbology: (SBSSymbology symbology
error: (NSError *_Nullable *_Nullable)  outError 

Instantiates a generator object.

Parameters
symbologyThe symbology to generate the image. It has to be one of the following values:
outErrorDescribes errors during the instantiation of the generator. The our parameters is set to nil on success. This method only returns a parser instance if the license used to instantiate the picker includes the usage of the Scandit Generator Library. Otherwise a nil pointer is returned.
Since
5.9.0
- (void) addWarningsObserver: (nullable id< SBSWarningsObserver >)  observer

Register a warnings observer for this barcode picker.

Parameters
observerThe observer to register. If the observer is nil, this method has no effect.
Since
5.11.1
- (void) removeWarningsObserver: (nullable id< SBSWarningsObserver >)  observer

Unregister a warnings observer for this barcode picker.

Parameters
observerThe observer to unregister. If the observer is nil, this method has no effect.
Since
5.11.1

Property Documentation

- (UIInterfaceOrientationMask) allowedInterfaceOrientations
readwritenonatomicassign

Orientations that the barcode picker is allowed to rotate to.

The orientations returned by this view controller's supportedInterfaceOrientations function. Be aware that this orientation mask will be taken into consideration only if this view controller is the root view controller or the topmost presented view controller. For example, this orientation mask will not be taken into consideration if the view controller is the root view controller of a UINavigationController (in that case the UINavigationController's supportedInterfaceOrientations matter). This orientation will also not be taken into consideration if this view controller's view is directly added to a view hierarchy.

By default all orientations are allowed (UIInterfaceOrientationMaskAll).

Since
4.7.0
- (SBSOverlayController*) overlayController
readwritenonatomicstrong

The overlay controller controls the scan user interface.

The Scandit BarcodeScanner contains a default implementation that developers can inherit from to define their own scan UI (enterprise licensees only).

Since
4.7.0
- (id<SBSScanDelegate>) scanDelegate
readwritenonatomicweak

The scan delegate for this barcode picker.

barcodePicker:didScan: (SBSScanDelegate-p) is invoked on the registered scanDelegate whenever a new barcode/2d code has been recognized. To react to barcode scanned events, you must provide a scan delegate that contains your application logic. Alternatively, you may register a SBSProcessFrameDelegate, which can be used to get notified whenever a frame has finished processing and process the scan events there.

Since
4.7.0
- (id<SBSProcessFrameDelegate>) processFrameDelegate
readwritenonatomicweak

The process frame delegate for this barcode picker.

barcodePicker:didProcessFrame:session: (SBSProcessFrameDelegate-p) is invoked on the registered processFrameDelegate whenever a frame has been processed by the barcode picker. Barcodes may or may not have been recognized in that frame. For most uses, you do not require to provide a processFrameDelegate, it is sufficient to just provide a scanDelegate instead.

Since
4.7.0
- (id<SBSLicenseValidationDelegate>) licenseValidationDelegate
readwritenonatomicweak

The license validation delegate for this barcode picker.

SBSLicenseValidationDelegate::barcodePicker:failedToValidateLicense:errorMessage: is invoked on the registered licenseValidationDelegate license validation fails. The possible reasons for the method to be called can be e.g. license expiration or missing API key.

Since
5.8.0
- (SBSCameraFacingDirection) cameraFacingDirection
readnonatomicassign

The facing direction of the used camera.

Since
2.0.0
- (AVCaptureVideoOrientation) cameraPreviewOrientation
readwritenonatomicassign

The orientation of the camera preview.

The orientation of the camera preview. In general the preview's orientation will be as wanted, but there may be cases where it needs to be set individually. This does not change the orientation of the overlayed UI elements.

Possible values are: AVCaptureVideoOrientationPortrait, AVCaptureVideoOrientationPortraitUpsideDown, AVCaptureVideoOrientationLandscapeLeft, AVCaptureVideoOrientationLandscapeRight

- (BOOL) autoFocusOnTapEnabled
readwritenonatomicassign

Whether tapping on the screen should trigger an auto-focus.

By default, the camera triggers an auto-focus whenever the user taps the screen. To disable this feature, set this property to NO.

- (BOOL) pinchToZoomEnabled
readwritenonatomicassign

Whether pinch to zoom is enabled.

By default, the camera preview zoom factor can be changed by using a pinch gesture. To disable this feature, set this property to NO. The feature is only available on devices with iOS 7 and greater.

Since
4.15
- (id<SBSTextRecognitionDelegate>) textRecognitionDelegate
readwritenonatomicweak

The text recognition settings to be used.

By default, the text recognition settings are set to nil. If you want to use the text recognition feature, you must set this property and configure the settings accordingly.

This feature is only available if you have text recognition enabled.

Since
5.1

Provided by category SBSBarcodePicker(TextRecognition).


The documentation for this class was generated from the following file: