如何在 Xcode 4 中的头文件和实现文件之间切换?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5300947/
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
How do I switch between the header and implementation file in Xcode 4?
提问by TheLearner
How do I switch between the header and implementation file in Xcode 4?
如何在 Xcode 4 中的头文件和实现文件之间切换?
In XCode 3 it was cmd and right or left (I think)
在 XCode 3 中,它是 cmd 和左右(我认为)
回答by zoul
Ctrl+Cmd+Upor Down, but the shortcut seems a bit finicky and sometimes stops working, not yet sure when and why.
Ctrl+ Cmd+Up或Down,但快捷方式似乎有点挑剔,有时会停止工作,尚不确定何时以及为什么。
Be sure to FIRST click ON the actual code window...
请务必首先单击实际代码窗口...
that's the critical tip to ensure it works. Click anywhere at all on the actual code. (If you're active in one of the other many panes of Xcode, the keystroke combo has no, or different, meaning(s).)
这是确保它有效的关键提示。单击实际代码上的任意位置。(如果您在 Xcode 的其他许多窗格之一中处于活动状态,则击键组合没有或不同的含义。)
回答by purplecabbage
Also, you can 3 finger swipe up and down on the touchpad if you have one.
此外,如果您有触摸板,您可以 3 指在触摸板上上下滑动。
回答by Gavin Thornton
Ctrl+Cmd+Up or Down
Ctrl+Cmd+向上或向下
The shortcut sometimes stops working!!
快捷方式有时会停止工作!!
The menu option has moved to "Navigate->Jump to Next Counterpart" and "Navigate->Jump to Previous Counterpart".
菜单选项已移至“导航->跳转到下一个对应物”和“导航->跳转到上一个对应物”。
In preferences the key binding is now under "Jump to Next Counterpart" and "Jump to Previous Counterpart".
在首选项中,键绑定现在位于“跳转到下一个对应物”和“跳转到上一个对应物”下。
Why Apple insist on changing the menu positions AND names of these things is beyond me! I mean "Counterpart"!?
为什么苹果坚持要改变这些东西的菜单位置和名称,我无法理解!我是说“对方”!?
Worth nothing that Ctrl+Cmd+Left or Right move between previous and next files that were viewed (I mean "counterparts") too. These are also under the key bindings "Jump to Next Counterpart" & "Jump to Previous Counterpart").
Ctrl+Cmd+Left 或 Right 在已查看的上一个和下一个文件之间移动(我的意思是“对应文件”)也毫无价值。这些也在键绑定“跳转到下一个对应对象”和“跳转到上一个对应对象”下)。
回答by D.McG.
The reason the menu option has been split between:
菜单选项被拆分的原因如下:
"Navigate->Jump to Next Counterpart" and "Navigate->Jump to Previous Counterpart"
“导航->跳转到下一个对应部分”和“导航->跳转到上一个对应部分”
is because you can have more than just one header file and one source file with the same file name. Besides having matching .xib files for view controllers, I have separate .vsh and .fsh files for vertex and fragment shaders in my OpenGL program. Along with my .h and .cpp files that's a list of 4 files that I can navigate up or down through with one key binding, instead of hitting the same key binding 3 times in a row to cycle back from file 2 to file 1.
是因为您可以拥有多个头文件和一个具有相同文件名的源文件。除了视图控制器的匹配 .xib 文件外,我的 OpenGL 程序中还有单独的 .vsh 和 .fsh 文件用于顶点和片段着色器。连同我的 .h 和 .cpp 文件,这是一个包含 4 个文件的列表,我可以使用一个键绑定向上或向下导航,而不是连续 3 次点击相同的键绑定以从文件 2 循环回文件 1。
回答by Luca Davanzo
Also in Xcode 6.1/7.1shortucts are the same:
同样在Xcode 6.1/7.1 中,快捷方式是相同的:
Jump to next counterpart:
Ctrl+Cmd+Up
跳转到下一个对手:
Ctrl+ Cmd+Up
Jum to previous counterpart:
Ctrl+Cmd+Down
Jum的以前的对手:
Ctrl+ Cmd+Down
Personally, coming from eclipse, I change this shortcut with:
就个人而言,来自 eclipse,我更改了这个快捷方式:
Ctrl+Tab
Ctrl+Tab
this combination insn't already binded to anything else.
这个组合尚未绑定到其他任何东西。
Xcode -> Preferences -> Key Bindings
search for "Jump to next counterpart" and put the new keys combination.
搜索“跳转到下一个对应项”并输入新的组合键。
PRO
专业版
This is more efficientthan default bindings see that you can use one hand instead of two!
这比默认绑定更有效,因为您可以使用一只手而不是两只手!
回答by Vincent
"but the shortcut seems a bit finicky and sometimes stops working, not yet sure when and why."
“但捷径似乎有点挑剔,有时会停止工作,尚不确定何时以及为什么。”
Sometimes Xcode loses track of which .m and .h belong together. This is e.g. the case when you open one of the files directly from the Finder. When you open the file from the file list in Xcode, it normally works okay. Although when you have moved files between folders & groups in the file list of Xcode, it will also list the relation between the files.
有时 Xcode 会忘记哪个 .m 和 .h 属于一起。例如,当您直接从 Finder 打开其中一个文件时就是这种情况。当您从 Xcode 的文件列表中打开文件时,它通常可以正常工作。虽然当你在 Xcode 的文件列表中的文件夹和组之间移动文件时,它也会列出文件之间的关系。
回答by Nathan Perry
The command to swap between m and h files is CTL-CMD-up/down. It sometimes get stuck. To unstick it simply save the file, i.e. CMD-S, and the hotkey should work again.
在 m 和 h 文件之间交换的命令是 CTL-CMD-up/down。它有时会卡住。要解开它,只需保存文件,即 CMD-S,热键应该会再次起作用。