JLChen
2021-02-03 4715e99a9be1c50d8ec31f594af9ebde18647c94
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
//
//  EZInputSerialViewController.m
//  EZOpenSDKDemo
//
//  Created by DeJohn Dong on 15/10/28.
//  Copyright © 2015年 Ezviz. All rights reserved.
//
 
#import "EZInputSerialViewController.h"
#import "DDKit.h"
 
@interface EZInputSerialViewController ()<UITextFieldDelegate>
 
@property (nonatomic, weak) IBOutlet UIButton *nextButton;
@property (nonatomic, weak) IBOutlet UITextField *serialTextField;
@property (weak, nonatomic) IBOutlet UITextField *verifyCodeTextField;
 
@end
 
@implementation EZInputSerialViewController
 
- (void)dealloc
{
    
}
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = NSLocalizedString(@"ad_input_manual", @"手动输入");
    
    self.serialTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 30)];
    self.serialTextField.leftViewMode = UITextFieldViewModeAlways;
    [self.serialTextField dd_addSeparatorWithType:ViewSeparatorTypeVerticalSide];
    
    self.verifyCodeTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 30)];
    self.verifyCodeTextField.leftViewMode = UITextFieldViewModeAlways;
    [self.verifyCodeTextField dd_addSeparatorWithType:ViewSeparatorTypeVerticalSide];
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
/*
#pragma mark - Navigation
 
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
 
- (void) checkContent
{
    if (self.serialTextField.text.length == 9 && self.verifyCodeTextField.text.length > 4)
    {
        self.nextButton.enabled = YES;
    } else
    {
        self.nextButton.enabled = NO;
    }
}
 
#pragma mark - UITextFieldDelegate Methods
 
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([self.serialTextField isEqual:textField])
    {
        [self checkContent];
        
        NSString *strTemp = [NSString stringWithFormat:@"%@%@", textField.text, string];
        if ([strTemp length] > 9)
        {
            return NO;
        }
    }
    else if ([self.verifyCodeTextField isEqual:textField])
    {
        [self checkContent];
        
        NSString *strTemp = [NSString stringWithFormat:@"%@%@", textField.text, string];
        if ([strTemp length] > 6)
        {
            return NO;
        }
    }
    
    return YES;
}
 
#pragma mark - Custom Methods
 
- (IBAction)go2Result:(id)sender
{
    [GlobalKit shareKit].deviceSerialNo = self.serialTextField.text;
    [GlobalKit shareKit].deviceVerifyCode = self.verifyCodeTextField.text;
    [GlobalKit shareKit].deviceModel = @"";
    
    [self performSegueWithIdentifier:@"go2InputResult" sender:nil];
}
 
@end