目录

HmsCustomScanViewController

定义全局hmsCustomScanViewController。扫码工具类,用于检测权限并启动扫码界面,提供Customized View扫码方式。

Declaration

@interface HmsCustomScanViewController : UIViewController

在调用方法中进行初始化,需要初始化DefaultScanView的代理方法:

HmsCustomScanViewController *hmsCustomScanViewController;
hmsDefaultScanViewController.defaultScanDelegate = self;
hmsCustomScanViewController = [[HmsCustomScanViewController alloc] init];

Properties

Name

Description

@property (nonatomic) BOOL backButtonHidden

设置隐藏返回按钮。格式如:backButtonHidden = true。

@property (nonatomic) BOOL continuouslyScan

设置是否持续扫码,默认为false。true为持续扫码。格式如:continuouslyScan = true。

@property (nonatomic) CGRect cutArea

设置Customized View扫码区域。格式如:CGRectMake(50, 50, 450, 450)。

backAction

页面返回需要调用的方法。

Declaration

-(void)backAction

customizedScanDelegateForResult

扫码返回结果数据的代理方法。

Declaration

-(void)customizedScanDelegateForResult:(NSDictionary *)resultDic

Returns

Type

Description

NSDictionary

扫码方式中扫码结果的回调NSDictionary数据,包含以下内容:

  • zoomValue:相机镜头放大系数。
  • text:码返回值。
  • exposureAdjustmentValue:曝光系数。
  • formatValue:码制式。
  • ResultPoint:码图角点坐标位置。
  • sceneType:场景类型。
  • parserDic:对应场景返回的值。其中包含有:
    • Contact(联系人信息)
    • Email(邮箱)
    • WebSite(URL链接)
    • ISBN
    • Location(地理位置信息)
    • SMS(SMS短信信息)
    • Tel(电话)
    • EVENT(日历事件信息)
    • Wi-Fi(Wi-Fi信息)

initCustomizedScanWithFormatType

设置扫码制式选项。

Declaration

-(instancetype)initCustomizedScanWithFormatType:(HmsScanOptions *)scanOptions

设置options参数并初始化ScanViewController:

HmsScanOptions *options = [[HmsScanOptions alloc] initWithScanFormatType:ALL Photo:FALSE];
self.hmsCustomScanViewController = [[HmsCustomScanViewController alloc] initCustomizedScanWithFormatType:options];
Parameters

Name

Description

Photo

代表相机扫码或图片扫码,此处传入FALSE为相机扫码。

ScanFormatType

ALL是枚举类型参数,可以用位运算符连接多种码制,如:QR_CODE | AZTEC。

pauseContinuouslyScan

暂停连续扫码。

Declaration

-(void)pauseContinuouslyScan

resumeContinuouslyScan

恢复连续扫码。

Declaration

-(void)resumeContinuouslyScan