Skip to content

Commit

Permalink
add inputBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
xjh093 committed Aug 23, 2019
1 parent ab5ed64 commit bd1fed8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef NS_ENUM(NSUInteger, JHVCConfigInputType) {

@interface JHVerificationCodeView : UIView

@property (copy, nonatomic) void (^inputBlock)(NSString *code);
@property (copy, nonatomic) void (^finishBlock)(NSString *code);

- (instancetype)initWithFrame:(CGRect)frame config:(JHVCConfig *)config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ - (void)xx_textChange:(NSNotification *)noti
text = [text substringToIndex:count];
}
_textView.text = text;
if (_inputBlock) {
_inputBlock(text);
}

NSLog(@"%@",text);
//NSLog(@"%@",text);

// set value
for (int i = 0; i < text.length; ++i) {
Expand Down
12 changes: 12 additions & 0 deletions JHVerificationCodeView/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ - (void)jhSetupViews
codeView.finishBlock = ^(NSString *code) {
label.text = code;
};
codeView.inputBlock = ^(NSString *code) {
NSLog(@"example 1 code:%@",code);
};
codeView.tag = 100;
codeView;
})];
Expand Down Expand Up @@ -120,6 +123,9 @@ - (void)jhSetupViews
codeView.finishBlock = ^(NSString *code) {
label.text = code;
};
codeView.inputBlock = ^(NSString *code) {
NSLog(@"example 2 code:%@",code);
};
codeView.tag = 200;
codeView;
})];
Expand Down Expand Up @@ -162,6 +168,9 @@ - (void)jhSetupViews
codeView.finishBlock = ^(NSString *code) {
label.text = code;
};
codeView.inputBlock = ^(NSString *code) {
NSLog(@"example 3 code:%@",code);
};
codeView.tag = 300;
codeView;
})];
Expand Down Expand Up @@ -206,6 +215,9 @@ - (void)jhSetupViews
codeView.finishBlock = ^(NSString *code) {
label.text = code;
};
codeView.inputBlock = ^(NSString *code) {
NSLog(@"example 4 code:%@",code);
};
codeView.tag = 400;
codeView;
})];
Expand Down

0 comments on commit bd1fed8

Please sign in to comment.