如何使选项卡在 Xcode 4 上正常工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5353220/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:48:00  来源:igfitidea点击:

How can I make the tabs work normally on Xcode 4?

xcodexcode4

提问by sorin

Xcode finally added tabs but the problem is that they behave very strange. For example they will keep a tab open only if it was opened to a new tab.

Xcode 终于添加了标签,但问题是它们的行为很奇怪。例如,只有当它被打开到一个新选项卡时,他们才会保持一个选项卡打开。

If you open a file just by clicking in the project tree, Xcode will close your tab as soon as you are clicking on another file in the tree.

如果您只是通过单击项目树来打开一个文件,那么只要您单击树中的另一个文件,Xcode 就会关闭您的选项卡。

Is is possible to make them behave like real tabs and prevent Xcode from reusing them? How?

是否可以让它们表现得像真正的选项卡并防止 Xcode 重用它们?如何?

采纳答案by Daniel

I don't think you can currently get the behavior you desire (or I desire). While the tabs work like Safari, they don't work like tabs in other popular IDEs (Visual Studio or Eclipse). And for me this kind of sucks.

我认为您目前无法获得您想要(或我想要)的行为。虽然选项卡的工作方式类似于 Safari,但它们的工作方式与其他流行 IDE(Visual Studio 或 Eclipse)中的选项卡不同。而对我来说,这种事情很糟糕。

In general, I expect IDE tabs to keep more than 1 file open. So if I click a file in the project tree, I expect that it will switch to the tab I have opened with that file - if I have already opened it. Instead, XCode 4 changes the current tab to the file I clicked - making 2 tabs with the same file. Having 2 tabs with the same file is fairly useless.

一般来说,我希望 IDE 选项卡可以保持 1 个以上的文件打开。因此,如果我单击项目树中的一个文件,我希望它会切换到我用该文件打开的选项卡 - 如果我已经打开了它。相反,XCode 4 将当前选项卡更改为我单击的文件 - 使用同一文件制作 2 个选项卡。有 2 个标签具有相同的文件是相当无用的。

This forces the user to scan the tab bar first to see if the file is currently opened; if it's not opened then you can look to the project tree. But if you click in the project tree first (which is what I tend to do) then you get punished because you will have just killed a tab.

这会强制用户首先扫描标签栏以查看文件当前是否已打开;如果它没有打开,那么你可以查看项目树。但是,如果您首先单击项目树(这是我倾向于做的事情),那么您将受到惩罚,因为您刚刚杀死了一个选项卡。

回答by dr?msynt

I use a method similar to franks:

我使用类似于弗兰克的方法:

  • In Preferences > Navigation(or Preferences > Generalin versions of XCode prior to 5) you can set Optional Navigationto Uses Separate Tab
  • Now opt-clicking a file in the file navigator will open it in a new tab
  • Better yet, opt-clicking links in the code opens the destination file in a new tab
  • Preferences > Navigation(或Preferences > General5 之前的 XCode 版本中),您可以将Optional Navigation设置为使用单独的选项卡
  • 现在选择 -单击文件导航器中的文件将在新选项卡中打开它
  • 更好的是,选择单击代码中的链接会在新选项卡中打开目标文件

The big feature missing is swapping to an already open tab containing the file if there is one (or staying in the current one).

缺少的重要功能是交换到包含文件的已打开选项卡(如果有)(或停留在当前选项卡中)。

回答by devios1

This isn't really an answer insofar as it contains a solution; I mostly just want to join in the griping. But upvoting will make you feel better and prove Apple wrong. :)

就包含解决方案而言,这并不是真正的答案;我主要只是想加入抱怨。但投票会让你感觉更好,并证明苹果是错的。:)

The problem with Xcode 4's implementation of tabs is that Apple has implemented them as workspace tabs. In other words, creating a new tab essentially creates a new workspace, each with its own sub-panes with their configurations, etc. It's essentially a whole environment in each tab. There are a number of problems with this choice.

Xcode 4 实现选项卡的问题在于 Apple 已将它们实现为工作区选项卡。换句话说,创建一个新选项卡本质上是创建一个新工作区,每个工作区都有自己的子窗格及其配置等。它本质上是每个选项卡中的整个环境。这个选择有很多问题。

This differs from most IDE/text editors' implementation of file tabswherein a tab (generally) represents a single file, and each file has its own tab.

这与大多数 IDE/文本编辑器的文件选项卡实现不同,其中选项卡(通常)代表单个文件,每个文件都有自己的选项卡。

The problem with workspace tabs is there are only so many potential different workspaces we could benefit from, severely limiting the actual use of tabs in this way. Beyond this, the additional workspaces just become a liability, introducing more things the user of the application needs to concern him/herself with: for example, what the navigator view is, what editor mode is active (standard, assistant, version), whether the debug console is open, etc. etc. Suddenly switching to a new tab means you now have to worry about getting the environment back in the form you need it, because there's a good chance the other tab wasn't left in the state you expect to find it in. This actually discourages the use of tabs because it introduces more workin the workflow.

工作区选项卡的问题在于我们可以受益的潜在不同工作区只有这么多,以这种方式严重限制了选项卡的实际使用。除此之外,额外的工作区只是一种负担,引入了更多应用程序用户需要关注的事情:例如,导航器视图是什么,什么编辑器模式处于活动状态(标准、助手、版本),是否调试控制台已打开,等等。突然切换到一个新选项卡意味着您现在必须担心将环境恢复到您需要的形式,因为另一个选项卡很可能没有留在您的状态希望能找到它。这实际上不鼓励使用选项卡,因为它会在工作流程中引入更多工作

File tabs don't have this problem (not counting special cases like split view panes) because all that's changing is the file you're looking at, not your whole environment. Moreover, if implemented properly, file tabs work great as an immediate history, allowing one to quickly switch back to a file that was worked in recently, with little effort. The only way to do this in Xcode is to explicitly set up a new tab environment for each file you want to work with, but you have to be careful not to change the file in that tab or your file all of a sudden becomes lost: again, more work for the user.

文件选项卡没有这个问题(不包括像拆分视图窗格这样的特殊情况),因为所有改变的是您正在查看的文件,而不是您的整个环境。此外,如果实施得当,文件选项卡可以很好地作为直接历史记录,让人们可以轻松快速地切换回最近使用过的文件。在 Xcode 中执行此操作的唯一方法是为您要使用的每个文件明确设置一个新的选项卡环境,但您必须小心不要更改该选项卡中的文件,否则您的文件会突然丢失:再次,为用户做更多的工作。

Workspace tabs are also significantly heavier-weight than file tabs, because there is much more to remember and switching workspaces involves much more than switching files.

工作区选项卡也比文件选项卡重得多,因为要记住的要多得多,切换工作区涉及的不仅仅是切换文件。

The truth is (and I think most will agree with me on this), to a developer, file tabs are muchmore useful than workspace tabs, and as it stands Xcode stilllacks a proper implementation of this feature that many would consider basic required functionality in an IDE/editor.

事实是,(我想大多数人会同意我这一点),给开发者,文件选项卡比工作空间标签更实用,因为它代表的Xcode仍然缺乏正确实施此功能的,很多会考虑基本需要的功能在 IDE/编辑器中。

回答by Luca

Xcode->Preferences->General->Double Click Navigationand from the list, choose Uses Separate Tab.

Xcode->Preferences->General->Double Click Navigation并从列表中选择Uses Separate Tab

回答by frank

Well, not a real answer but my personal workaround. The real problem for me is, that a file opened in a tab goes away so easily in xcode 4. Finding a file again can be time-consuming, so I like them to be in a tab and stay there.

好吧,这不是真正的答案,而是我个人的解决方法。对我来说真正的问题是,在 xcode 4 中打开的文件在标签中很容易消失。再次查找文件可能很耗时,所以我喜欢它们在标签中并留在那里。

I solved this (somehow) for me by exactly identifying the actions I do which cause the tab to switch to another file and replace them by their equivalent actions which open a new tab instead.

我通过准确识别我所做的导致选项卡切换到另一个文件的操作(以某种方式)为我解决了这个问题,并将它们替换为打开新选项卡的等效操作。

  • Instead of single-clicking a file in the navigator, I always double-click which I have set to open a new tab
  • Most time I do not use the navigator, as it has a different state of opened and closed folders in each tab. Not useful for me. So I switched to using Option ?Command ?O. When opening a file from this list I keep ShiftOption ?pressed. In the small window appearing I choose 'new tab'.
  • When clicking on links in code I press ShiftOption ?Command ?, too, and open in new tab.
  • 而不是单击导航器中的文件,我总是双击我设置的打开一个新选项卡
  • 大多数时候我不使用导航器,因为它在每个选项卡中打开和关闭文件夹的状态不同。对我没用。所以我改用 Option ?Command ?O. 从这个列表中打开一个文件时,我一直ShiftOption ?按下。在出现的小窗口中,我选择“新标签”。
  • 单击代码中的链接时,我也按ShiftOption ?Command ?,然后在新选项卡中打开。

I keep two fixed tabs around for editing target-related settings and to view build results. I completely disabled all automatic tab switching in the prefs, because I noticed this distracted me to much.

我保留了两个固定选项卡,用于编辑与目标相关的设置并查看构建结果。我完全禁用了首选项中的所有自动选项卡切换,因为我注意到这让我分心。

I would really love to get something like the xcode 3 favorites bar in xcode 4, this was so simple to use..

我真的很想在 xcode 4 中获得类似 xcode 3 收藏夹栏的东西,这使用起来非常简单。

回答by j03m

I imagine my answer won't bubble up for a while, but if you want this to work like visual studio or intellij (or at least closer)

我想我的答案暂时不会冒泡,但是如果您希望它像 Visual Studio 或 Intellij 一样工作(或至少更接近)

Preferences->General->Double Click Navigation->Uses a separate tab

首选项->常规->双击导航->使用单独的标签

Double Clicking a file now will stop opening it in a new window and open it in a new tab.

现在双击文件将停止在新窗口中打开它并在新选项卡中打开它。

Single is still dumb and takes over your tab. But if you get used to double clicking (which I was already) this will save you some headaches. I suppose.

Single 仍然是愚蠢的,并接管了你的标签。但是,如果您习惯了双击(我已经习惯了),这将为您省去一些麻烦。我想。

回答by mithun_daa

I absolutely hate how tabs work in Xcode. However, the only workaround i found that works decent is using the OSX tabs shortcuts: CTRL + CMD + -> CTRL + CMD + <-

我非常讨厌标签在 Xcode 中的工作方式。但是,我发现唯一可行的解​​决方法是使用 OSX 选项卡快捷方式:CTRL + CMD + -> CTRL + CMD + <-

回答by Matthias Grob

I found my way in Preferences-Behaviors!

我在 Preferences-Behaviors 中找到了自己的方式!

I hated Xcode 4 first for the tab issues discussed here, mainly because the debug information kept opening new files in tabs and changing the navigator

我首先因为这里讨论的选项卡问题而讨厌 Xcode 4,主要是因为调试信息不​​断在选项卡中打开新文件并更改导航器

in Behaviors you can define a Debug tab and make the Run and Build jump there in various ways. in the Debug tab I give more space to navigators left and bottom

在 Behaviors 中,您可以定义一个 Debug 选项卡并使 Run 和 Build 以各种方式跳转到那里。在调试选项卡中,我为导航器左侧和底部提供了更多空间

for similar reasons I have a Find tab, too

出于类似的原因,我也有一个“查找”选项卡

the other tabs are for files I am writing in. I start them with the .h which is usually small enough so I need only one view, and then with single clicks in the navegator I open 2-3 versions of the .cpp file so I can set them to the locations where the recent hot spots in the file are. then I close the navigators in those tabs

其他选项卡用于我正在写入的文件。我以 .h 开头,它通常足够小,所以我只需要一个视图,然后在导航器中单击一下,我就可以打开 2-3 个版本的 .cpp 文件,因此我可以将它们设置为文件中最近热点所在的位置。然后我关闭这些选项卡中的导航器

this does not invalidate the care and tricks given in the other answers here, but makes them far less hard

这不会使此处其他答案中给出的小心和技巧无效,但使它们变得不那么难

happy coding!

快乐编码!

回答by Hendrik

I found out that when pressing optiona.k.a. altwhen opening files in the navigator, you will jump to the tab already open with the file and a new tab will open in case it was not yet open.

我发现在导航器中打开文件时按optionakaalt时,您将跳转到已打开文件的选项卡,如果尚未打开,则会打开一个新选项卡。

This technique also works when opening files via cmdshift-Oand opening the suggestion with option-enterin stead of simply enter...

当通过cmdshift-打开文件O并使用option-enter而不是简单地打开建议时,此技术也适用enter...

Now, if there would be some way to make this the default, i.e. the need to keep pressing optionall the time would be removed, that would be a big step forward.

现在,如果有某种方法可以将其设为默认值,即不再需要一直按下option,那将是向前迈出的一大步。

Also I use Behaviors to keep my tabs from being recycled after test or build failures.

我还使用行为来防止我的标签在测试或构建失败后被回收。

(Like other people, I totally mislike Xcode's tab behavior. Apple should take a look at IntelliJ...)

(和其他人一样,我完全不喜欢 Xcode 的标签行为。Apple 应该看看 IntelliJ ......)

回答by lbsweek

xcode tab bar is so suck, I think Apple should enhance the feature of the tab navigation to avoid followed 3 points. 1. double click a file will let xcode open another tab if it has already been there. 2. for more tabs, the tab will become small and thus I don't know which file in which tab, I want the tab show full name 3. for even more tabs, new tabs will be hidden, instead of two lines of tabs. I want to it show two lines of tab bars.

xcode 标签栏太烂了,我认为苹果应该增强标签导航的功能,以避免遵循 3 点。1.双击一个文件会让xcode打开另一个选项卡,如果它已经存在的话。2.对于更多的标签,标签会变小,因此我不知道哪个文件在哪个标签中,我希望标签显示全名 3.对于更多的标签,将隐藏新标签,而不是两行标签. 我想显示两行标签栏。