ios 向标签栏控制器添加新标签

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

Adding new tabs to a tab bar controller

iosxcodeuitabbarcontroller

提问by mvasco

I am creating a tab bar iOS app. The tab bar view controller has two tabs, each of them connected to a view controller.

我正在创建一个标签栏 iOS 应用程序。标签栏视图控制器有两个标签,每个标签都连接到一个视图控制器。

This how it looks:

这是它的外观:

enter image description here

在此处输入图片说明

I need to add more tabs to the tab controller. I am doing it at the storyboard as follows:

我需要向选项卡控制器添加更多选项卡。我在情节提要上按如下方式进行:

  1. I add a new view controller.
  2. I control-drag from the tab bar controller to the new created view controller.
  3. A window opens and I select Relationship Segue-View Controller.
  4. The segue from the tab bar controller to the new view controller is created.
  1. 我添加了一个新的视图控制器。
  2. 我从标签栏控制器控制拖动到新创建的视图控制器。
  3. 一个窗口打开,我选择关系 Segue-View Controller。
  4. 创建从标签栏控制器到新视图控制器的 segue。

I think that is the way to do it, but after that the tab bar controller doesn't show any tab icons, the tab bar becomes grey.

我认为这是这样做的方法,但之后标签栏控制器不显示任何标签图标,标签栏变为灰色。

Like this:

像这样:

enter image description here

在此处输入图片说明

I need to know what am I doing wrong.

我需要知道我做错了什么。

回答by Pandey_Laxman

First drag A TabBarController from Object Library you see that only two tabs with thier VC there.

首先从对象库中拖动一个 TabBarController,您会看到那里只有两个带有 VC 的选项卡。

to add more Tab Item in TabBarVC drag VC from Object Library

要在 TabBarVC 中添加更多选项卡项,请从对象库中拖动 VC

Then Control drag from TabBarVC to Newly VC then Segue relation pop ups

然后控制从 TabBarVC 拖动到 Newly VC 然后 Segue 关系弹出窗口

Select last one RelationshipSegue -> View Controllers

选择最后一个RelationshipSegue -> View Controllers

Here is the Screen

这是屏幕

回答by Tom Manterfield

I had the same problem until I added a tab bar item from the object library into the new view (settings its attributes on the right hand panel) and THEN ctrl dragged from the tab bar controller to the new view, creating a relationship segue.

我遇到了同样的问题,直到我将对象库中的选项卡栏项目添加到新视图中(在右侧面板上设置其属性),然后 ctrl 从选项卡栏控制器拖动到新视图,创建关系转场。

If I tried to ctrl drag from the tab controller without first adding a tab item to the new view, it had the behaviour you described.

如果我在没有先向新视图添加选项卡项的情况下尝试从选项卡控制器中按住 ctrl 拖动,则它具有您描述的行为。

回答by user2744053

be sure to check the size of your icon image. the tint of image added is grey by default. If you have a large sized tab bar image, it can look like the whole tab bar is greyed out for some reason. pic does not auto resize.

请务必检查图标图像的大小。添加的图像色调默认为灰色。如果您有一个大尺寸的标签栏图像,它可能看起来像由于某种原因整个标签栏都变灰了。图片不会自动调整大小。

回答by Charlin Decok

bellow process is follow in Xcode 9.4 for adding new item in tab bar controller. 1)Drag and Drop new Tab Bar Controller into sotrtyboard 2)It will show 2 item which connected with 2 view controller. 3)For adding third item button in tab bar controller i) Add new View Controller. ii) Right click on Tab Bar Controller and Drag into new view controller. iii) one option popup will display inside that popup select "view controllers" options

在 Xcode 9.4 中遵循波纹管过程在标签栏控制器中添加新项目。1) 将新的 Tab Bar Controller 拖放到 sotrtyboard 2) 它将显示与 2 个视图控制器连接的 2 个项目。3) 在标签栏控制器中添加第三个项目按钮 i) 添加新的视图控制器。ii) 右键单击​​ Tab Bar Controller 并拖入新的视图控制器。iii) 一个选项弹出窗口将显示在该弹出窗口中选择“视图控制器”选项

It will create relationship link and will generate automatic item button in tab bar controller.

它将创建关系链接并在标签栏控制器中生成自动项目按钮。

回答by NSTNF

need to add/drag icon (from showing the media library) to the 3rd view controller, so that it can display properly.

需要添加/拖动图标(从显示媒体库)到第三个视图控制器,以便它可以正确显示。

回答by Chi-Hwa Michael Ting

Restarting Xcode 6.1.1 solved the issue for me while I was working on multiple projects.

在我处理多个项目时,重新启动 Xcode 6.1.1 为我解决了这个问题。