在segue之后保持标签栏在View上? [英] Keeping tab bar on View after segue?

查看:90
本文介绍了在segue之后保持标签栏在View上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签栏控制器,然后是导航控制器,然后是第一个视图控制器。此视图控制器具有预期的标签栏。但是,当我离开这个视图时,我失去了标签栏。我希望它能够保留其在另一个VC上的位置,这源于第一个观点。这是我的IB:

I have a tab bar controller, then a navigation controller, then a first view controller. This view controller has a tab bar as expected. However, when I segue from this view I lose the tab bar. I want it to retain its position on the other VC's stemming from this first view. Here is my IB:

我想要标签栏在从右侧VC通过segue加载后也出现在左侧VC上,

I want the tab bar to also appear on the left VC after it is loaded via segue from the right VC,

如何实现这一目标,因为无论我设置标签部分,它都会消失在VC的底部,如上所示。

How is this achieved as currently it disappears regardless of me setting the tab section at the bottom of the VC as shown above.

推荐答案

如果你从一个标签栏视图的视图中做一个模态segue,它将摆脱标签栏您正在呈现的模态视图。

If you do a modal segue from a view that is a tab bar view, it will get rid of the tab bar for the modal view you are presenting.

其次,当您进行segue时,您正在创建视图控制器的新实例。所以我猜你是从view1到view2并且丢失了标签栏,然后你又回到了view1。此时你已经创建了view1,view2和没有标签栏的view1的第二个副本。

Secondly, when you segue you are creating a new instance of the view controller. So I am guessing you are segueing from view1 to view2 and losing the tab bar, then you are segueing back to view1. At this point you have created view1, view2, and a second copy of view1 that does not have a tab bar.

我建议两件事之一。

1。)如果你想在从view1转到view2时将标签保持在底部,然后点击view1,在屏幕顶部选择Editor / Embed In /导航控制器。这会将您的view1嵌入导航控制器中。然后,如果您将segue从Modal更改为Push,它将使标签栏保持在底部。顶部的导航栏还可以轻松地从视图2返回到视图1以正确的方式(通过弹出视图)而不是创建新的segue。如果您不喜欢导航栏,则可以在检查器中将顶栏属性更改为无。然后,您需要在view2中创建一些其他方法以返回view1。 (通过弹出控制器,而不是通过分割)

1.) If you want to keep the tabs at the bottom when you segue from view1 to view2, then click on view1, at the top of the screen select Editor/Embed In/ Navigation Controller. This will embed your view1 in a navigation controller. Then if you change your segue from Modal to Push it will keep your tab bars at the bottom. The navigation bar at the top also make it easy to go back from view 2 to view 1 the correct way (by popping the view) rather than creating a new segue. If you do not like the navigation bar, then you can change the "Top Bar" property to "None" in the inspector. You will then need to create some other way in view2 to get back to view1. (BY POPPING THE CONTROLLER, NOT BY SEGUEING)

2)如果你不想设置导航控制器,那么保留标签会有点困难在view2控制器底部的条形图。事实上,我不确定你是否可以使用模态segue完成它,你可能不得不写一些类型的自定义segue。无论哪种方式,如果你想转换回view1并转到正确的控制器(不是没有选项卡的新版本),那么你需要将一个动作附加到用于segue的任何按钮并使用以下代码(我也附上)导航控制器推送segue的代码,以防您创建导航控制器并摆脱导航栏。)

2) If you don't want to set up a navigation controller you will have a little bit harder time keeping the tab bar stuff at the bottom of the view2 controller. In fact, I'm not sure you can do it at all with a modal segue, you'd probably have to write some type of custom segue. Either way, If you want to transition back to view1 and get to the correct controller (not a new version without the tabs) then you need to attach an action to whatever button you are using to segue and use the following code (I also attached the code for navigation controller push segues, in case you create a navigation controller and get rid of the navigation bar.)

对于Modal Segue:

For Modal Segue:

[self dismissModalViewControllerAnimated:YES];

对于Push segue:

For Push segue:

[self.navigationController popViewControllerAnimated:YES];

您最好的选择是使用导航控制器方法,因为您可以放心使用。然后你可以使用导航栏返回(简单的方法,不需要代码),或者你可以摆脱它并使用上面的代码按钮。

Your best bet is to use the navigation controller method, as you are assured to keep your tabs. You can then either use the navigation bar to return (the easy way, no code needed) or you can get rid of it and use a button and the code above.

祝你好运!
如果有帮助,请点击绿色复选标记

Good luck! Please Click On the Green Checkmark if this helps

这篇关于在segue之后保持标签栏在View上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆