123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //
- // UserAuthBodyView.m
- // KulexiuForTeacher
- //
- // Created by 王智 on 2022/5/27.
- //
- #import "UserAuthBodyView.h"
- @interface UserAuthBodyView ()<UITextFieldDelegate>
- @property (nonatomic, copy) AuthSureCallback callback;
- @end
- @implementation UserAuthBodyView
- - (void)awakeFromNib {
- [super awakeFromNib];
- self.nameField.delegate = self;
- self.cardField.delegate = self;
- }
- + (instancetype)shareInstance {
- UserAuthBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"UserAuthBodyView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)sureAuthCall:(AuthSureCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (IBAction)sureAction:(id)sender {
- if (self.callback) {
- self.callback();
- }
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- [string replaceAll:@" " WithString:@""];
- if ([string isEqualToString:@"\n"]) {
- [self endEditing:YES];
- return YES;
- }
- // 输入控制
- NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
- if (textField == self.cardField) {
- if (newString.length > 18) {
- return NO;
- }
- }
- return YES;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|