ios 如何在选项卡视图控制器故事板应用程序中添加更多选项卡?

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

How to add more tabs in tab view controller storyboard application?

iphoneobjective-ciostabsstoryboard

提问by AskMe

Possible Duplicate:
Xcode 4.2 Tabbed Application - Adding New Tab view

可能重复:
Xcode 4.2 选项卡式应用程序 - 添加新选项卡视图

I'm new to iPhone app and I followed following tutorialto develop a tab view application using story board:

我是 iPhone 应用程序的新手,我按照以下教程使用故事板开发选项卡视图应用程序:

It's working fine.Thanks to the Author. :)

它工作正常。感谢作者。:)

Now, I want to add couple of more tabs to the main view(default, its 2 tabs; I want 3 or 4).

现在,我想向主视图添加更多选项卡(默认为 2 个选项卡;我想要 3 或 4 个)。

How Can I do it?

我该怎么做?

回答by rptwsthi

Add one view controller (UIViewController) And Add it with your tabBarController in relationship "View Controllers"(To do this right click on tab bar controller and drag it to new view controller and select bottom most relationship seague, i.e. view controller), your XIB page should look like:

添加一个视图控制器(UIViewController)并将其与您的 tabBarController 添加到关系“视图控制器”(为此右键单击选项卡栏控制器并将其拖动到新的视图控制器并选择最底部的关系海格,即视图控制器),您的 XIB页面应如下所示:

enter image description here

在此处输入图片说明

You can apply same pattern for the rest.

您可以对其余部分应用相同的模式。

To Add Controller Files

添加控制器文件

As @Jamie Said: You have to go to the menu and click on "New File", then Objective-C class, and finally make sure to select UIViewController subclass. Name it and then it will add the files. Now in your storyboard make sure to change the class of each tab to the name of your file. i.e. to assign custom class for your ViewController this I have used Name AAA for that in Image.

正如@Jamie 所说:您必须转到菜单并单击“新建文件”,然后单击 Objective-C 类,最后确保选择 UIViewController 子类。命名它,然后它将添加文件。现在在您的故事板中,确保将每个选项卡的类更改为您的文件名。即为您的 ViewController 分配自定义类,我在 Image 中使用了名称 AAA。

回答by iShwar

Just add one more View controller on the screen drag it from the controls, then hold the right click on tab bar controller bring that click on the newly added view controller and left the click the four options will be appear there choose the topmost option by clicking on it its name is "Relationships-view controllers" . and its done.

只需在屏幕上再添加一个视图控制器,将其从控件中拖出,然后在标签栏控制器上右键单击,然后单击新添加的视图控制器,然后左键单击将出现四个选项,单击选择最上面的选项它的名字是“关系视图控制器”。它完成了。