-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathQRCodeReaderViewController.h
191 lines (168 loc) · 7.23 KB
/
QRCodeReaderViewController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* QRCodeReaderViewController
*
* Copyright 2014-present Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#import <UIKit/UIKit.h>
#import "QRCodeReaderDelegate.h"
#import "QRCodeReader.h"
/**
* Convenient controller to display a view to scan/read 1D or 2D bar codes like
* the QRCodes. It is based on the `AVFoundation` framework from Apple. It aims
* to replace ZXing or ZBar for iOS 7 and over.
*/
@interface QRCodeReaderViewController : UIViewController
#pragma mark - Creating and Inializing QRCodeReader Controllers
/** @name Creating and Inializing QRCode Reader Controllers */
/**
* @abstract Initializes a view controller to read QRCodes from a displayed
* video preview and a cancel button to be go back.
* @param cancelTitle The title of the cancel button.
* @discussion This convenient method is used to instanciate a reader with
* only one supported metadata object types: the QRCode.
* @see initWithCancelButtonTitle:metadataObjectTypes:
* @since 1.0.0
*/
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle;
/**
* @abstract Creates a view controller to read QRCodes from a displayed
* video preview and a cancel button to be go back.
* @param cancelTitle The title of the cancel button.
* @see initWithCancelButtonTitle:
* @since 1.0.0
*/
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle;
/**
* @abstract Initializes a reader view controller with a list of metadata
* object types.
* @param metadataObjectTypes An array of strings identifying the types of
* metadata objects to process.
* @see initWithCancelButtonTitle:metadataObjectTypes:
* @since 3.0.0
*/
- (nonnull id)initWithMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
/**
* @abstract Creates a reader view controller with a list of metadata object
* types.
* @param metadataObjectTypes An array of strings identifying the types of
* metadata objects to process.
* @see initWithMetadataObjectTypes:
* @since 3.0.0
*/
+ (nonnull instancetype)readerWithMetadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
/**
* @abstract Initializes a view controller to read wanted metadata object
* types from a displayed video preview and a cancel button to be go back.
* @param cancelTitle The title of the cancel button.
* @param metadataObjectTypes The type (“symbology”) of barcode to scan.
* @see initWithCancelButtonTitle:codeReader:
* @since 2.0.0
*/
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle metadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
/**
* @abstract Creates a view controller to read wanted metadata object types
* from a displayed video preview and a cancel button to be go back.
* @param cancelTitle The title of the cancel button.
* @param metadataObjectTypes The type (“symbology”) of barcode to scan.
* @see initWithCancelButtonTitle:metadataObjectTypes:
* @since 2.0.0
*/
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle metadataObjectTypes:(nonnull NSArray *)metadataObjectTypes;
/**
* @abstract Initializes a view controller using a cancel button title and
* a code reader.
* @param cancelTitle The title of the cancel button.
* @param codeReader The reader to decode the codes.
* @see initWithCancelButtonTitle:codeReader:startScanningAtLoad:
* @since 3.0.0
*/
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader;
/**
* @abstract Initializes a view controller using a cancel button title and
* a code reader.
* @param cancelTitle The title of the cancel button.
* @param codeReader The reader to decode the codes.
* @see initWithCancelButtonTitle:codeReader:
* @since 3.0.0
*/
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader;
/**
* @abstract Initializes a view controller using a cancel button title and
* a code reader.
* @param cancelTitle The title of the cancel button.
* @param codeReader The reader to decode the codes.
* @param startScanningAtLoad Flag to know whether the view controller start
* scanning the codes when the view will appear.
* @see initWithCancelButtonTitle:codeReader:
* @since 3.0.0
*/
- (nonnull id)initWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad;
/**
* @abstract Initializes a view controller using a cancel button title and
* a code reader.
* @param cancelTitle The title of the cancel button.
* @param codeReader The reader to decode the codes.
* @param startScanningAtLoad Flag to know whether the view controller start
* scanning the codes when the view will appear.
* @see initWithCancelButtonTitle:codeReader:startScanningAtLoad:showSwitchCameraButton:showTorchButton:
* @since 3.0.0
*/
+ (nonnull instancetype)readerWithCancelButtonTitle:(nullable NSString *)cancelTitle codeReader:(nonnull QRCodeReader *)codeReader startScanningAtLoad:(BOOL)startScanningAtLoad;
#pragma mark - Controlling the Reader
/** @name Controlling the Reader */
/**
* @abstract Starts scanning the codes.
* @since 3.0.0
*/
- (void)startScanning;
/**
* @abstract Stops scanning the codes.
* @since 3.0.0
*/
- (void)stopScanning;
#pragma mark - Managing the Delegate
/** @name Managing the Delegate */
/**
* @abstract The object that acts as the delegate of the receiving QRCode
* reader.
* @since 1.0.0
*/
@property (nonatomic, strong) id<QRCodeReaderDelegate> __nullable delegate;
/**
* @abstract Sets the completion with a block that executes when a QRCode
* or when the user did stopped the scan.
* @param completionBlock The block to be executed. This block has no
* return value and takes one argument: the `resultAsString`. If the user
* stop the scan and that there is no response the `resultAsString` argument
* is nil.
* @since 1.0.1
*/
- (void)setCompletionWithBlock:(nullable void (^) (NSString * __nullable resultAsString))completionBlock;
#pragma mark - Managing the Reader
/** @name Managing the Reader */
/**
* @abstract The default code reader created with the controller.
* @since 3.0.0
*/
@property (strong, nonatomic, readonly) QRCodeReader * __nonnull codeReader;
@end