系统没有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 输入验证码或密码,自动下一位的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持VEVB武林网。
新闻热点
疑难解答