SBSDKBarcodeScannerViewController

@interface SBSDKBarcodeScannerViewController : UIViewController

UIViewController subclass showing a camera screen and barcode detector. This class cannot be instanced from a storyboard. Instead it is installing itself as a child view controller onto a given parent view controller.

  • The delegate. See SBSDKBarcodeScannerViewControllerDelegate protocol. Weak.

    Declaration

    Objective-C

    @property (nonatomic, weak, readwrite, nullable)
        id<SBSDKBarcodeScannerViewControllerDelegate>
            delegate;

    Swift

    weak var delegate: SBSDKBarcodeScannerViewControllerDelegate? { get set }
  • The controllers camera session.

    Declaration

    Objective-C

    @property (nonatomic, readonly) SBSDKCameraSession *_Nonnull cameraSession;

    Swift

    var cameraSession: SBSDKCameraSession { get }
  • The desired maximum detection rate of the receicer. The maximum number of video frames per second to

    • be analyzed. Defaults to 20.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        NSUInteger detectionRate;

    Swift

    var detectionRate: UInt { get set }
  • If set to YES (default), the camera session will be stopped entirely, when the receiver disappears and restarts when the receiver reappears. There is no CPU usage while the receiver is not on screen.

    NO will NOT stop the camera session, but pause the delivery of video frames and barcodes. There is some very low CPU activity while the receiver is not on screen, but there is also no lag when the receiver returns to the screen.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL stopsCameraSessionWhenDisappeared;

    Swift

    var stopsCameraSessionWhenDisappeared: Bool { get set }
  • Specifies the way of barcode images generation or disables this generation at all. Use, if you want to receive a full sized image with barcodes. Defaults to SBSDKBarcodeImageGenerationTypeNone.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        SBSDKBarcodeImageGenerationType barcodeImageGenerationType;

    Swift

    var barcodeImageGenerationType: SBSDKBarcodeImageGenerationType { get set }
  • Machine code types (EAN, DataMatrix, Aztec, QR, etc) that can be returned in didDetectBarcodes delegate method. When nil or empty - all codes can be returned. Default is nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, readwrite, nullable)
        NSArray<SBSDKBarcodeType *> *acceptedBarcodeTypes;

    Swift

    var acceptedBarcodeTypes: [SBSDKBarcodeType]? { get set }
  • Specifies the amount of frames barcode scanner takes before detecting. Uses the sharpest frame. So setting more frames generally improves recognition quality, but reduces recognition speed. Keep in mind, that detectionRate also has influence on recognition speed, as it determines the amount of frames that can be read per second. Default to 5.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        NSInteger barcodeAccumulatedFramesCount;

    Swift

    var barcodeAccumulatedFramesCount: Int { get set }
  • A transparent view that lies over the preview layer. You can add custom UI here. Read-only.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nonnull) UIView *HUDView;

    Swift

    var hudView: UIView { get }
  • Defines if barcodeScanner should use limiting frame for detection. Alternatively all camera frame will be used.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL shouldUseFinderFrame;

    Swift

    var shouldUseFinderFrame: Bool { get set }
  • Defines the region of interest when scanning barcodes or other machine readable codes. Machine readable codes found outside this region of interest are discarded and ignored during detection. The property describes the aspect ratio (width / height) of the region of interest. This aspect ratio, in conjunction with the screen size and capturingFrameMinimumInset parameter, is used to create an absolute region of interest and render a view finder like rounded rectangle on screen. The 0 aspect ratio effectively disables the region of interest.

    Note: Only effective if shouldUseFinderFrame is set to YES.

    Declaration

    Objective-C

    @property (nonatomic, strong, readwrite)
        SBSDKAspectRatio *_Nonnull capturingFrameAspectRatio;

    Swift

    var capturingFrameAspectRatio: SBSDKAspectRatio { get set }
  • Defines a minimum inset for capturing frame. Width goes for horizontal inset, height - for vertical. Default is 32 for both parameters.

    To calculate maximum size of the finder frame you need to take the corresponding inset, multiply it by 2, and subtract it from finder’s container corresponding side. Example: If capturingFrameMinimumInset.width == 32 and finder’s container width == 320, the maximum width of finder frame will be 320 - (32 * 2) = 256

    Note: Only effective if shouldUseFinderFrame is set to YES.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        UIEdgeInsets capturingFrameMinimumInset;

    Swift

    var capturingFrameMinimumInset: UIEdgeInsets { get set }
  • Background color of camera preview. Default is black. Can be nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, readwrite, nullable)
        UIColor *previewBackgroundColor;

    Swift

    var previewBackgroundColor: UIColor? { get set }
  • Background color of the view finder. Default is white with 0.66 alpha. Must not be nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, readwrite, nonnull)
        UIColor *viewFinderBackgroundColor;

    Swift

    var viewFinderBackgroundColor: UIColor { get set }
  • Line color of the view finder. Default is nil, which draws no border line for the view finder.

    Declaration

    Objective-C

    @property (nonatomic, strong, readwrite, nullable) UIColor *viewFinderLineColor;

    Swift

    var viewFinderLineColor: UIColor? { get set }
  • Line width of the view finder. Default is 2.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        CGFloat viewFinderLineWidth;

    Swift

    var viewFinderLineWidth: CGFloat { get set }
  • Set to YES to toggle on the video light. Defaults to NO.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL flashLightEnabled;

    Swift

    var flashLightEnabled: Bool { get set }
  • Not available.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Not available.

    Declaration

    Objective-C

    + (nonnull instancetype)new;
  • Designated initializer. Installs the receiver as child view controller onto the parent view controllers view using its entire bounds area.

    Declaration

    Objective-C

    - (nullable instancetype)initWithParentViewController:
                                 (nonnull UIViewController *)parentViewController
                                               parentView:
                                                   (nullable UIView *)containerView;

    Swift

    init?(parentViewController: UIViewController, parentView containerView: UIView?)

    Parameters

    parentViewController

    The view controller the newly created instance is embedded into. If parentViewController conforms to SBSDKBarcodeScannerViewControllerDelegate, it is automatically set as delegate.