张家口沽源杀人案,陈馨儿,快乐美美向前冲0706
系统没有textfeild 的相关当输入内容改变时候的代理方法。。。所以我们自己加一个监听来实现如下的效果
自动跳转下一位
主要代码如下:
[_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];
-(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 输入验证码或密码,自动下一位的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
iOS 使用UITextField自定义搜索框 实现用户输入完之后“实时搜索”功能
网友评论