Custom Camera Controller UI

For greater control you can build out your own UI that sits on top of our base camera controller. To do so, subclass BRCameraViewController and create your UI programmatically or in Interface Builder.

#import <BlinkReceipt/BlinkReceipt.h>

@interface MyCameraController : BRCameraViewController

Your camera controller interacts with properties and methods of its superclass to facilitate the scanning experience.

Initial Setup

  • You must set the background of your view to be transparent so that the camera preview underneath will be visible.
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor clearColor];
}
  • It is recommended to set BRCameraViewController.scanningRegion so that the area of the camera preview that is visible to the user corresponds to the region that is cropped out of the full camera frame for scanning. For example, to indicate that your UI uses margins of 10% screen width on the left and right, a margin of 5% on top, and some controls that occupy 30% on the bottom, you would use the following:
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    self.scanningRegion = CGRectMake(0.1, 0.05, 0.8, 0.65);
}

Note

The components of this property are percentages not absolute pixel values. They must all be between 0.0 and 1.0.

Basic Scanning

There are 3 base class methods for which you should provide UI in order to enable basic scanning functionality:

  1. -[BRCameraViewController userSnappedPhotoOnReady:] - Call this method when the user attempts to snap a picture (such as a press on a camera button)
  2. -[BRCameraViewController userConfirmedFrame:] - Call this method when the user has indicated they are satisfied with the image that was returned by the previous call (this is necessary to ensure the image is saved properly at session end)
  3. -[BRCameraViewController userFinishedScan] - Call this method when the user indicates the scan session is complete
  4. -[BRCameraViewController userCancelledScan] - Call this method when the user cancels the scan session

Extended Functionality

See the BRCameraViewController documentation for extended functionality:

  • “Base Class Methods” are methods you can call to control aspects of the scan session

  • “Subclass Methods” are methods you can implement that allow the base class to notify your subclass of various conditions during the scan session

Starting a Scan Session with a Custom Controller

To begin a scan session with your custom controller use the following:

MyCameraController *cameraController = [MyCameraController new]; //or instantiate from storyboard

[[BRScanManager sharedManager] startCustomCamera:cameraController
                                  fromController:self
                                     scanOptions:scanOptions
                                    withDelegate:self];