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

2025-05-29 0 66

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

自动跳转下一位

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

主要代码如下:

?

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 输入验证码密码,自动下一位的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持快网idc。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 iOS 输入验证码或密码,自动下一位的实例 https://www.kuaiidc.com/89907.html

相关文章

发表评论
暂无评论