当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS 输入验证码或密码,自动下一位的实例

iOS 输入验证码或密码,自动下一位的实例

2019年07月24日  | 移动技术网IT编程  | 我要评论

张家口沽源杀人案,陈馨儿,快乐美美向前冲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 输入验证码或密码,自动下一位的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网