Tab 键(键盘)操作的 TextField becomeFirstResponder 问题 [英] TextField becomeFirstResponder Issue for tab key(Keyboard) action

查看:25
本文介绍了Tab 键(键盘)操作的 TextField becomeFirstResponder 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XIB 中有一个视图,我在其中使用了几个文本字段.假设一旦视图加载到窗口中,第一个文本字段就会成为第一响应者.如果我按机器键盘上的 Tab 键导航到下一个文本字段;除了直接文本字段之外,所有其他文本字段也将成为第一响应者,并且所有文本字段都会调用文本字段开始编辑委托方法.可能是什么问题 ?这不仅会发生在模拟器中,当我们使用机器的键盘时也会发生,当我们在 iOS 设备上使用蓝牙键盘时也会发生.

I have a view in XIB where i used several text fields in it. Let say the first text field becomes first responder as soon as the view gets loaded in the window. If i press tab key in my machine's keyboard to navigate to next text field ;apart from the immediate text field, all other text fields are also becomes first responder and the textfield begin editing delegate menthod gets called for all the text fields. What could be the issue ? This will occur not only in simulator when we use machine's keyboard also when we use bluetooth keyboard for a iOS device.

推荐答案

按 Tab 键 => 导航到与视图中文本字段的层次结构相关的下一个文本字段.

Pressing of tab key => navigation to next textfield with respect to heirarchy of the textfields in the view.

当您按下 Tab 键时 - textfieldshouldbeginediting 将被调用与您的 textfields 一样多的次数 - 意思是 - 5 个 textfields => 按一次 Tab 键,所有 5 个实例都将被调用.当您按 Tab 键时 - textfielddidbeginediting 将仅针对新文本字段的实例调用一次 - 因此,文本字段的任何逻辑最好使用 textfielddidbeginediting 委托方法.

When u press tab - textfieldshouldbeginediting will be called as many times as you textfields - meaning - 5 textfields => one tab key press, all the 5 instances will be called. When you press tab - textfielddidbeginediting will be called only once with respect to the new textfield's instance - Hence any logic for the textfield is better to be in textfielddidbeginediting delegate method.

这些是委托方法的默认特征,不是问题.

These are the default characteristics of the delegate methods and not an issue.

这篇关于Tab 键(键盘)操作的 TextField becomeFirstResponder 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆