当前位置: 移动技术网 > 移动技术>移动开发>Android > OC 使用手机号获取验证码,添加国家编码

OC 使用手机号获取验证码,添加国家编码

2020年07月08日  | 移动技术网移动技术  | 我要评论

由于项目受众群里不是国内用户,所以在使用手机号获取验证码的时候需要添加国家编码。

三行代码集成国家区号选择功能

功能运行效果如图:

国家代码 UI

设置TextField的左padding

NSInteger m = 40;
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, m, 40)];
self.textField.leftView = paddingView;
self.textField.leftViewMode = UITextFieldViewModeAlways;

然后将国家编码的按钮叠加在TextField上面就可以了。

 

国家代码开源链接: 国家编码

使用方法:

1.导入XWCountryCode类

2.在需要选择国家代码的事件中

XWCountryCodeController *CountryCodeVC = [[XWCountryCodeController alloc] init];
    //CountryCodeVC.deleagete = self;
    //block
    [CountryCodeVC toReturnCountryCode:^(NSString *countryCodeStr) {
    //在此处实现最终选择后的界面处理
    [self.countryCodeLB setText:countryCodeStr];
}];
[self presentViewController:CountryCodeVC animated:YES completion:nil];


 

本文地址:https://blog.csdn.net/shanghaibao123/article/details/107183061

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网