更改 Xcode 故事板中视图控制器的列表顺序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12585551/
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
Change the listing order of the view controllers in Xcode storyboard
提问by Darren
I'm just starting my first application using storyboards. I'm using Xcode 4.5 and iOS 6 SDK. I want to know how to change the order in which the controllers are listed in the Document Outline (panel to the left of the storyboard).
我刚刚使用故事板开始我的第一个应用程序。我正在使用 Xcode 4.5 和 iOS 6 SDK。我想知道如何更改控制器在文档大纲(故事板左侧的面板)中列出的顺序。
采纳答案by obj-D
In the Document Outline, drag the orange view controller icon. As you do this you will see the blue horizontal insertion point appear between the grey boxes. Let go and the whole grey group box for the view controller will relocate.
在文档大纲中,拖动橙色视图控制器图标。执行此操作时,您将看到蓝色水平插入点出现在灰色框之间。放手,视图控制器的整个灰色组框将重新定位。
回答by Viktor Kucera
In Xcode 11you just open storyboard XML and move specific "scene" to proper place under "scenes" tag. And that's it. The order will correspond to Document outline.
在Xcode 11 中,您只需打开故事板 XML 并将特定的“场景”移动到“场景”标签下的适当位置。就是这样。该顺序将对应于文档大纲。
回答by Denton
In Xcode 5, the order of the view controllers/scenes listed in the storyboard's "Document Outline" seems to be determined by an alphanumeric sorting of the sceneID attribute values in the storyboard XML file.
在 Xcode 5 中,故事板的“文档大纲”中列出的视图控制器/场景的顺序似乎是由故事板 XML 文件中场景 ID 属性值的字母数字排序决定的。
After upgrading to Xcode 5 from 4.6 the Document Outline seemed to list my scenes in a random order. I inspected the Storyboard XML file (right click on storyboard file -> Open As -> Source Code) but the order of the scenes was correct. After further investigation I realized the sceneID attribute values were the issue. I found each sceneID attribute and added an alphanumerically increasing prefix to the value. For example, for the first scene that should appear in the Document Outline I prefixed its sceneID value with a "1a", for the second "1b", for the third "1c" and so on. After doing that for all my scenes, they had a proper listing order in the Document Outline.
从 4.6 升级到 Xcode 5 后,文档大纲似乎以随机顺序列出了我的场景。我检查了情节提要 XML 文件(右键单击情节提要文件 -> 打开为 -> 源代码),但场景的顺序是正确的。经过进一步调查,我意识到sceneID 属性值是问题所在。我找到了每个 sceneID 属性,并为该值添加了一个字母数字递增的前缀。例如,对于应该出现在文档大纲中的第一个场景,我在它的场景 ID 值前面加上“1a”,第二个“1b”,第三个“1c”,依此类推。在对我的所有场景执行此操作后,它们在文档大纲中具有正确的列表顺序。
I think the sceneID values are probably only used for unique identification/ordering purposes, so hopefully changing them doesn't cause other unexpected problems. But I'm still able to work with the storyboard in Interface Builder without problems and my app seems to work normally. So if this problem is irritating you as much as it did me, you might consider this workaround until Apple gives us a proper solution... just be sure to make a backup first!
我认为 sceneID 值可能仅用于唯一标识/排序目的,因此希望更改它们不会导致其他意外问题。但是我仍然可以毫无问题地使用 Interface Builder 中的故事板,而且我的应用程序似乎可以正常工作。所以如果这个问题和我一样让你恼火,你可以考虑这个解决方法,直到 Apple 给我们一个合适的解决方案......一定要先备份!
回答by SonicBison
At least for Xcode 4.6 , the scenes are in the order they're stored in the storyboard xml.
至少对于 Xcode 4.6 来说,场景是按照它们在 storyboard xml 中的存储顺序排列的。
So you can open it with a text editor and reorder the tags to you liking, and start Xcode.
因此,您可以使用文本编辑器打开它并根据自己的喜好重新排列标签,然后启动 Xcode。
回答by Maxim Berezovsky
I am not sure if it is still meaningfull for you. As of xcode 6.1 you can rightclick your storyboard file, choose "Open as..." -> "Source code" and change the order of view controllers rearranging sections order. I can't move them by drag'n'dropping view controller icons for unknown reason, so it is the only way that works for me.
我不确定它对你是否仍然有意义。从 xcode 6.1 开始,您可以右键单击故事板文件,选择“打开为...”->“源代码”并更改视图控制器重新排列部分顺序的顺序。由于未知原因,我无法通过拖放视图控制器图标来移动它们,因此这是对我有用的唯一方法。
回答by Thai Tran
For Xcode 5.1.1, you have to change the order of tag segue
. Open the storyboard
as source code
(Right Click -> Open As -> Source code)
对于 Xcode 5.1.1,您必须更改 tag 的顺序segue
。打开storyboard
为source code
(右键单击 -> 打开为 -> 源代码)
<segue destination="Bdn-Z8-Ql8" kind="relationship" relationship="viewControllers" id="0DS-1d-02F"/>
<segue destination="KY3-Z9-s1u" kind="relationship" relationship="viewControllers" id="u45-Ly-JkB"/>
<segue destination="k72-nP-MyV" kind="relationship" relationship="viewControllers" id="TAj-be-l8p"/>
<segue destination="gcA-x5-8Iw" kind="relationship" relationship="viewControllers" id="B7T-js-1Vs"/>
Changing the order of the above lines will change order of ViewControllers
更改上述行的顺序将更改 ViewControllers 的顺序
回答by Cthutu
It seems that the view controllers belong to the tab bar controller, so the order of the buttons determine the order not the position of the view controllers on the screen. You should be able to drag and drop the buttons.
似乎视图控制器属于标签栏控制器,所以按钮的顺序决定了视图控制器在屏幕上的位置。您应该能够拖放按钮。