ios 尝试将第三个选项卡添加到 tabBarController

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

Trying to add 3rd tab to tabBarController

iostabbarcontroller

提问by Michele

I'm trying to add a 3rd tab to the tabBarController using ios5. The standard object you get when you drag it out to your storyboard has 2 tabs. Does anyone know how to do this? I searched the internet and all examples start with their tabBarController with the extra tabs without showing how to get it.

我正在尝试使用 ios5 向 tabBarController 添加第三个选项卡。将它拖到故事板时获得的标准对象有 2 个选项卡。有谁知道如何做到这一点?我搜索了互联网,所有示例都以他们的 tabBarController 开头,并带有额外的选项卡,而没有显示如何获取它。

采纳答案by The iOSDev

for third tab first add a view controller and then right click the tabview controller and then from it's storyboard segway from relation controll drag to the added view controller and it's done

对于第三个选项卡,首先添加一个视图控制器,然后右键单击 tabview 控制器,然后从它的故事板 segway 从关系控件拖动到添加的视图控制器,就完成了

回答by Suragch

Here is the video I watched that taught me how to add a third tab to a TabBarController:

这是我观看的视频,教我如何向 TabBarController 添加第三个选项卡:

I will summarize the process below.

下面我总结一下这个过程。

Create a new Tabbed Application project

创建一个新的选项卡式应用程序项目

enter image description here

在此处输入图片说明

This will automatically provide two tabs that already "just work".

这将自动提供两个已经“正常工作”的选项卡。

enter image description here

在此处输入图片说明

Add new View Controller

添加新的视图控制器

Drag another view controller onto the storyboard.

将另一个视图控制器拖到故事板上。

enter image description here

在此处输入图片说明

Add Tab Bar Item

添加标签栏项目

Drag a Tab Bar Item onto the new View Controller that you just added.

将 Tab Bar Item 拖到您刚刚添加的新视图控制器上。

enter image description here

在此处输入图片说明

Connect to Tab View Controller

连接到选项卡视图控制器

Click and Control-Drag from the Tab View Controller to your new View Controller. A menu will pop up. Choose the view controllersoption under the Relationship Seguegroup.

单击并按住 Control 从选项卡视图控制器拖动到新的视图控制器。会弹出一个菜单。在Relationship Segue组下选择视图控制器选项。

enter image description here

在此处输入图片说明

That's it. You should be able to run it now and have all three tabs work. Watch the video that I linked to for more details.

就是这样。您现在应该能够运行它并让所有三个选项卡都正常工作。观看我链接到的视频以了解更多详细信息。

Note:

笔记:

  • To do anything on your new tab, don't forget to add a new View Controller class (as you would for any new View Controller).
  • 要在新选项卡上执行任何操作,请不要忘记添加新的视图控制器类(就像添加任何新的视图控制器一样)。

回答by Roozbeh Zabihollahi

Based on Wolvorin and Tom van responses, and based on what I have experienced you should do as following:

根据 Wolvorin 和 Tom van 的回答,并根据我的经验,您应该执行以下操作:

  1. Create an empty View Controller(in Controllers and Objects)
  2. From Windows and Bars, drag Tab Bar Itemto the newly added view
  3. From the main View Controller, select Tab Bar Controllericon (next to First Responder), and Control-Drag to the newly added View
  4. BOOM you have new tab
  1. 创建一个空的View Controller(在控制器和对象中)
  2. 从 Windows 和 Bars,拖动Tab Bar Item到新添加的视图
  3. 从主视图控制器中,选择Tab Bar Controller图标(First Responder 旁边),然后按住 Control 拖动到新添加的视图
  4. BOOM 你有新标签

回答by Peter Kaminski

To expound on @Roozbeh 's answer, when you control drag from the Tab Bar Controller to the newly added view controller, make sure you select the view controller option under Relationship Seque

为了阐述@Roozbeh 的答案,当您控制从 Tab Bar Controller 拖动到新添加的视图控制器时,请确保选择 Relationship Seque 下的视图控制器选项

Control drag from here

从这里控制拖动

And select view controllers under Relationship Seque

并在关系序列下选择视图控制器

I was reading this question after having the same problem and I wanted to clarify what the exact step was.

我在遇到同样的问题后正在阅读这个问题,我想澄清一下确切的步骤是什么。

回答by Tom van der Woerdt

Look in the right part of the screen, I believe it's the Objects library view. Just find the "Tab Item" (or something) and drag it into the bar.

查看屏幕的右侧部分,我相信它是对象库视图。只需找到“Tab Item”(或其他东西)并将其拖到栏中即可。