SFVerificationCodeView
==============
SFVerificationCodeView,实现iOS本地生成随机验证码, 从服务器读取并生成验证码
验证码其实主要用来防止机器人恶意注册与登陆,基本用于web网页端
![image](https://raw.githubusercontent.com/shaojiankui/SFVerificationCodeView/master/s.png)
## XIB拖拽方式
```
//设置验证码生成模式 服务器端生成验证码
self.codeView.mode = SFVerificationCodeModeServer;
[self.codeView willChangeVerificationCode:^(SFVerificationCodeMode mode) {
NSLog(@"请求服务器生成code");
[self getData:nil completion:^(NSDictionary *dict) {
self.codeView.code = [dict objectForKey:@"code"];
}];
}];
[self.codeView didChangeVerificationCode:^(NSString *code) {
NSLog(@"self.codeView code:%@",code);
}];
//开始生成code
[self.codeView generateVerificationCode];
//模拟异步从后台接口请求验证码
- (void)getData:(id)data completion:(void (^)(NSDictionary *dict))completion{
//网络请求
NSString *code = [NSString stringWithFormat:@"server%zd",arc4random() % 100];
NSDictionary *dict = @{@"code":code};
completion(dict);
}
```
## 代码方式
```
//设置验证码生成模式 本地生成验证码
view.mode = SFVerificationCodeModeLocal;
[view willChangeVerificationCode:^(SFVerificationCodeMode mode) {
NSLog(@"本地随机生成code");
}];
[view didChangeVerificationCode:^(NSString *code) {
NSLog(@"view code:%@",code);
}];
//开始生成code
[view generateVerificationCode];
```
没有合适的资源?快使用搜索试试~ 我知道了~
About SFVerificationCodeView,实现iOS本地生成随机验证码, 从服务器读取并生成验证码 验证码其
共19个文件
m:5个
h:4个
xib:1个
需积分: 0 0 下载量 62 浏览量
2023-06-11
09:47:02
上传
评论
收藏 61KB ZIP 举报
温馨提示
//设置验证码生成模式 服务器端生成验证码 self.codeView.mode = SFVerificationCodeModeServer; [self.codeView willChangeVerificationCode:^(SFVerificationCodeMode mode) { NSLog(@"请求服务器生成code"); [self getData:nil completion:^(NSDictionary *dict) { self.codeView.code = [dict objectForKey:@"code"]; }]; }]; [self.codeView didChangeVerificationCode:^(NSString *code) { NSLog(@"self.codeView code:%@",code); }]; //开始生成code [self.codeView generateVerificationCode]; //模拟异步从后台接口请求验证码 - (void)getData:(id
资源推荐
资源详情
资源评论
收起资源包目录
SFVerificationCodeView-master.zip (19个子文件)
SFVerificationCodeView-master
s.png 50KB
LICENSE 1KB
SFVerificationCodeView-Demo
ViewController.h 328B
Images.xcassets
AppIcon.appiconset
Contents.json 585B
Base.lproj
Main.storyboard 5KB
LaunchScreen.xib 4KB
AppDelegate.h 286B
AppDelegate.m 2KB
main.m 343B
ViewController.m 2KB
SFVerificationCodeView
SFVerificationCodeView.m 5KB
SFVerificationCodeView.h 1KB
Info.plist 1KB
SFVerificationCodeView-Demo.xcodeproj
project.pbxproj 12KB
project.xcworkspace
contents.xcworkspacedata 219B
.gitignore 504B
SFVerificationCodeView
SFVerificationCodeView.m 5KB
SFVerificationCodeView.h 1KB
README.md 1KB
共 19 条
- 1
资源评论
图灵软件技术
- 粉丝: 597
- 资源: 73
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功