forked from lych0317/AuthCodeView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppViewController.m
More file actions
47 lines (38 loc) · 1.58 KB
/
Copy pathAppViewController.m
File metadata and controls
47 lines (38 loc) · 1.58 KB
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
#import "AppViewController.h"
#define CountForText 4
@interface AppViewController ()
@end
@implementation AppViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor whiteColor]];
// 加载验证码View
AuthCodeView *codeViewText = [[AuthCodeView alloc] initWithType:AuthCodeViewTypeText];
[codeViewText setFrame:CGRectMake(.0, .0, 64.0, 30.0)];
[codeViewText setCenter:CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2 - 30)];
codeViewText.dataSource = self;
[self.view addSubview:codeViewText];
[codeViewText release];
AuthCodeView *codeViewURL = [[AuthCodeView alloc] initWithType:AuthCodeViewTypeURL];
[codeViewURL setFrame:CGRectMake(.0, .0, 64.0, 30.0)];
[codeViewURL setCenter:CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2 + 30)];
codeViewURL.dataSource = self;
[self.view addSubview:codeViewURL];
[codeViewURL release];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
/**
* 实现代理方法,根据实现方式返回文本或者URL
**/
- (NSString *)authCodeView:(AuthCodeView *)p_view withType:(AuthCodeViewType)p_type {
if (p_type == AuthCodeViewTypeText) {
char data[CountForText];
for (int x = 0; x < CountForText; data[x++] = (char)('A' + (arc4random_uniform(26))));
return [[NSString alloc] initWithBytes:data length:CountForText encoding:NSUTF8StringEncoding];
} else {
return @"http://114.80.86.70:27001/ebppManage/example/codeImages.jsp";
}
}
@end