3.3. ZBarReaderController Class Reference

class ZBarReaderController
Inherits from:UIImagePickerController

This is the controller to use for scanning images selected by a UIImagePickerController either captured manually using the camera, or selected from the Photo Library. For more information, see Scanning a User-Selected Image.

It can support automatic capture from the camera only if the library is re-built to use private APIs (see Backward Compatibility).

3.3.1. Properties

ZBarImageScanner* scanner

Access to the image scanner for configuration. (read-only)

id<ZBarReaderDelegate> readerDelegate

The delegate that will be notified when new barcode results are available.

BOOL showsZBarControls

Whether to display a default control set consisting of cancel, scan and info buttons. Disable these if you provide your own controls using the cameraOverlayView. Enabling this automatically disables the system controls showsCameraControls. (Default YES).

BOOL showsHelpOnFail

Whether to automatically display the integrated help viewer when an image fails to decode. Even if this is disabled, the integrated help may still be presented manually using showHelpWithReason:. (Default YES)

ZBarReaderControllerCameraMode cameraMode

Scanning mode to use with the camera. It is generally appropriate to leave this at the default.

BOOL tracksSymbols

Whether to display the tracking rectangle around detected barcodes.

BOOL takesPicture

Whether to take a full picture (with takePicture) when a barcode is detected with ZBarReaderControllerCameraModeSampling. The resulting image will be delayed from the actual decode.

BOOL enableCache

This property is deprecated and should not be modified.

CGRect scanCrop

Crop images before scanning. The original image will be cropped to this rectangle, which should be in normalized image coordinates, x-axis major. Defaults to the full image {{0, 0}, {1, 1}}.

NSInteger maxScanDimension

Scale image to scan. After cropping, the image will be scaled if necessary, such that neither of its dimensions exceed this value. Defaults to 640.

Note

The remaining properties are inherited from UIImagePickerController.

UIImagePickerControllerSourceType sourceType

Image source. Use to select between the camera and photo library.

BOOL showsCameraControls

Whether to display the system camera controls. Overridden to NO when showsZBarControls is YES.

UIView* cameraOverlayView

A custom view to display over the camera preview. The tracking layer and default controls will be added to this view if they are enabled.

CGAffineTransform cameraViewTransform

A transform to apply to the camera preview. Ignored by the reader. Possibly useful for eg, a digital zoom effect.

BOOL allowsEditing

Whether to enable the system image editing dialog after a picture is taken. Possibly useful to improve reader results in some cases using manual intervention.

3.3.2. Instance Methods

- (void) showHelpWithReason:(NSString*)reason

Display the integrated help browser. Use this with custom overlays if you don’t also want to create your own help view. Should only be called when the reader is displayed. The reason argument will be passed to the onZBarHelp() javascript function.

Reason :A string parameter passed to javascript.
- (id <NSFastEnumeration>) scanImage:(CGImageRef)image

Scan an image for barcodes. This is a wrapper around scanner.scanImage that applies scanCrop and maxScanDimension. Some additional result filtering is also performed.

Image :A CGImage to scan.
Returns :The result set containing ZBarSymbol objects.

3.3.3. Constants

type ZBarReaderControllerCameraMode

The scanning mode to use with the camera.

ZBarReaderControllerCameraModeDefault
The standard mode provided by UIImagePickerController - the user manually captures an image by tapping a control. This is the default unless private APIs are enabled.
ZBarReaderControllerCameraModeSampling
Automatically capture by taking screenshots with UIGetScreenImage(). Resolution is limited to the screen resolution, so this mode is inappropriate for longer codes. Only available when private APIs are enabled, and becomes the default mode in that case.
ZBarReaderControllerCameraModeSequence
Experimental mode that automatically scans by “rapidly” scanning pictures captured with takePicture. Not recommended for serious use.
NSString *ZBarReaderControllerResults

The info dictionary key used to return decode results to imagePickerController:didFinishPickingMediaWithInfo: