Skip to content

Commit bd1fed8

Browse files
committed
add inputBlock
1 parent ab5ed64 commit bd1fed8

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

JHVerificationCodeView/JHVerificationCodeView/JHVerificationCodeView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ typedef NS_ENUM(NSUInteger, JHVCConfigInputType) {
8282

8383
@interface JHVerificationCodeView : UIView
8484

85+
@property (copy, nonatomic) void (^inputBlock)(NSString *code);
8586
@property (copy, nonatomic) void (^finishBlock)(NSString *code);
8687

8788
- (instancetype)initWithFrame:(CGRect)frame config:(JHVCConfig *)config;

JHVerificationCodeView/JHVerificationCodeView/JHVerificationCodeView.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ - (void)xx_textChange:(NSNotification *)noti
276276
text = [text substringToIndex:count];
277277
}
278278
_textView.text = text;
279+
if (_inputBlock) {
280+
_inputBlock(text);
281+
}
279282

280-
NSLog(@"%@",text);
283+
//NSLog(@"%@",text);
281284

282285
// set value
283286
for (int i = 0; i < text.length; ++i) {

JHVerificationCodeView/ViewController.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ - (void)jhSetupViews
7777
codeView.finishBlock = ^(NSString *code) {
7878
label.text = code;
7979
};
80+
codeView.inputBlock = ^(NSString *code) {
81+
NSLog(@"example 1 code:%@",code);
82+
};
8083
codeView.tag = 100;
8184
codeView;
8285
})];
@@ -120,6 +123,9 @@ - (void)jhSetupViews
120123
codeView.finishBlock = ^(NSString *code) {
121124
label.text = code;
122125
};
126+
codeView.inputBlock = ^(NSString *code) {
127+
NSLog(@"example 2 code:%@",code);
128+
};
123129
codeView.tag = 200;
124130
codeView;
125131
})];
@@ -162,6 +168,9 @@ - (void)jhSetupViews
162168
codeView.finishBlock = ^(NSString *code) {
163169
label.text = code;
164170
};
171+
codeView.inputBlock = ^(NSString *code) {
172+
NSLog(@"example 3 code:%@",code);
173+
};
165174
codeView.tag = 300;
166175
codeView;
167176
})];
@@ -206,6 +215,9 @@ - (void)jhSetupViews
206215
codeView.finishBlock = ^(NSString *code) {
207216
label.text = code;
208217
};
218+
codeView.inputBlock = ^(NSString *code) {
219+
NSLog(@"example 4 code:%@",code);
220+
};
209221
codeView.tag = 400;
210222
codeView;
211223
})];

0 commit comments

Comments
 (0)