xcode 界面生成器中的选项卡顺序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4261865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tab Order in interface builder?
提问by JasonGenX
Perhaps the hour is late, but I can't find where I can set the overall Tab Order of my interface viewer dialog, just like I can with Visual Studio.
也许时间已经晚了,但我找不到可以设置界面查看器对话框的整体 Tab 顺序的位置,就像我在 Visual Studio 中所做的那样。
am I missing something? The tab order is all crooked. Command-R to simulate shows it.
我错过了什么吗?标签顺序都是歪的。Command-R 模拟显示它。
回答by Nicholas Riley
The Cocoa term you're looking for is "key view loop". Use the initialFirstResponder
and nextKeyView
outlets to connect the views together in the order you'd like to tab through them.
您正在寻找的 Cocoa 术语是“关键视图循环”。使用initialFirstResponder
和nextKeyView
插座按照您想要浏览的顺序将视图连接在一起。
This is mentioned in the documentation here.
Note that the items which can receive keyboard focus will change depending on the Full Keyboard Access setting (in System Preferences > Keyboard); if disabled, tabbing will skip over various items in your key view loop.
请注意,可以接收键盘焦点的项目将根据完整键盘访问设置(在系统偏好设置 > 键盘中)而变化;如果禁用,选项卡将跳过关键视图循环中的各种项目。
回答by Anoop Vaidya
Let the outlets are named as a, b and c. Mac default tab order is a -> b -> c -> a
让出口被命名为 a、b 和 c。Mac 默认的 Tab 键顺序是a -> b -> c -> a
But Your desired tab order is a -> c -> b ->a
:
但您想要的 Tab 键顺序是a -> c -> b ->a
:
Using IB:
使用IB:
Set a
as the initialFirstResponder
.
设置a
为initialFirstResponder
。
Then put the nextKeyView accordingly as a to c, c to b and c to a
.
然后将 nextKeyView 相应地作为a to c, c to b and c to a
.
But I prefer using codes, here it become easier to add more. As in complex UI there may be 30+ controls and you might require to shuffle and even insert new control!!!
但我更喜欢使用代码,在这里添加更多代码变得更容易。在复杂的 UI 中可能有 30 多个控件,您可能需要随机播放甚至插入新控件!!!
So you can achieve the same as :
所以你可以实现与:
[self.a setNextKeyView:self.c];
[self.c setNextKeyView:self.b];
[self.b setNextKeyView:self.a];
回答by Troy
I have found that placing the group of textfields in a separate view will help control the order in which the elements get their focus.
我发现将文本字段组放在单独的视图中将有助于控制元素获得焦点的顺序。
I tested in the simulator and on an iPad. It worked well for me.
我在模拟器和 iPad 上进行了测试。它对我来说效果很好。