如何在iOS中设置Tab键顺序? [英] How do you set the tab order in iOS?

查看:756
本文介绍了如何在iOS中设置Tab键顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法(在IB或代码中)在视图中的文本字段之间设置Tab键顺序?

Is there a way (either in IB or code) to set the tab order between text fields in a view?

请注意,在按下返回(或下一步)按钮后,我不是在谈论下一个表单字段 - 许多蓝牙键盘都有一个tab键,似乎以完全不同的顺序循环遍历字段。在我的特定情况下,此顺序与视图中字段的位置或甚至是添加字段的顺序不对应。手动修改xib文件以更改NSNextKeyView似乎也没有什么区别。

Note that I'm not talking about the next form field after the return (or "Next") button is pressed -- many bluetooth keyboards have a tab key, which seems to cycle through the fields in completely different order. In my particular case, this order doesn't correspond to the fields' position in the view or even the order in which the fields were added. Modifying the xib file by hand to change the NSNextKeyView doesn't seem to make a difference either.

有谁知道如何更改此订单?

Does anyone know how to change this order?

推荐答案

我有兴趣解决同样的问题,虽然到目前为止默认顺序似乎是从左到右,从上到下,是我想要的那个。

I'm interested in solving the same problem, although so far the default order, which appears to be left to right, then top to bottom, is the one I want.

我测试了光标通过子视图树和超视图以深度优先顺序移动的假设,但是不是真的。更改子视图的顺序而不更改其位置不会更改 tab 按下的字段顺序。

I tested the hypothesis that the cursor moves in depth-first order through the tree of subviews and superview, but that is not true. Changing the order of subviews without changing their location didn't change the order of fields traversed by tab presses.

一个可能有用的功能是似乎为应用程序窗口中的每个文本字段调用了文本字段委托的textFieldShouldBeginEditing方法。如果返回NO,则不会选择文本字段,因此如果您可以定义所需的订单并且仅使用正确的订单返回YES,则可能会解决您的问题。

One possibly useful feature is that the text field delegate's textFieldShouldBeginEditing method appears to be called for every text field in the application's window. If that returns NO, then the text field won't be chosen, so if you can define your desired order and make only the right one return YES, that might solve your problem.

这篇关于如何在iOS中设置Tab键顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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