系统没有textfeild 的相关当输入内容改变时候的代理方法。。。所以我们自己加一个监听来实现如下的效果
自动跳转下一位

主要代码如下:
?| 1 2 3 4 5 6 7 |
[_code1f becomefirstresponder];
[_code1f addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged];
[_code2f addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged];
[_code3f addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged];
[_code4f addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged];
[_code5f addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged];
[_code6f addtarget:self action:@selector(textfielddidchange:) forcontrolevents:uicontroleventeditingchanged];
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
-(void)textfielddidchange :(uitextfield *)textfield{
if (textfield.text.length == 1) {
if (textfield == _code1f) {
[_code2f becomefirstresponder];
}else if (textfield == _code2f){
[_code3f becomefirstresponder];
}else if (textfield == _code3f){
[_code4f becomefirstresponder];
}else if (textfield == _code4f){
[_code5f becomefirstresponder];
}else if (textfield == _code5f){
[_code6f becomefirstresponder];
}else{
[self.view endediting:yes];
}
}
}
|
以上这篇ios 输入验证码或密码,自动下一位的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:http://blog.csdn.net/kaiccy/article/details/78924277








发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。