简体   繁体   English

如何在标签栏控制器中从一个视图控制器切换到另一个视图控制器并保留标签栏?

[英]How within a tab bar controller do I segue from one view controller to another and retain the tab bar?

I have an application with several view controllers controlled from a tab bar controller. 我有一个应用程序,其中有几个视图控制器由标签栏控制器控制。 From one of these view controllers I want to (on clicking a button) segue to another view controller and retain the tab bar at the bottom of the segued to view. 从我想要的其中一个视图控制器(在单击按钮上)转到另一个视图控制器并保留要查看的segued底部的标签栏。

I've used 我用过

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([segue.identifier isEqualToString:@"newView"]){
        UIViewController *controller =segue.destinationViewController;
        controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController:controller animated:YES];
    }
 }

This works fine except the tab bar is missing from the segued to view (a placeholder shows for it in the storyboard, but it doesn't show up when the app is run) I've also tried replacing 这样工作正常,除了从视图到视图中缺少标签栏(占位符在故事板中显示它,但在应用程序运行时它不会显示)我也尝试过更换

[self presentModalViewController:controller animated:YES];

with

[self presentViewController:controller animated:YES completion:nil];

but that doesn't work either. 但这也不起作用。

A bit of debugging shows that for the segued-to view controller, the tabBarController property is set to nil. 一些调试显示,对于segued-to视图控制器,tabBarController属性设置为nil。

Is there anyway to retain the tab bar in the segued-to view controller? 反正有没有保留标签栏在segued-to视图控制器?

From your explanation, I don't think you want a modal controller. 根据你的解释,我不认为你想要一个模态控制器。 Modal is used to overlay, rendering your tab bar useless. 模态用于叠加,使标签栏无效。 From your storyboard, select your segue and select push, not modal. 从故事板中,选择您的segue并选择推送,而不是模态。

在此输入图像描述

Push vs Modal (Note the tab bar): Push vs Modal(注意标签栏):

在此输入图像描述在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从标签栏视图 controller 转到另一个视图,该视图是导航 controller 的子视图 - How to segue from tab bar view controller to another view which is a child of a navigation controller 在一个标签栏控制器中从一个ViewController切换到另一个ViewController? - Segue from one ViewController to another ViewController inside a Tab Bar Controller? 如何使用segue将图像从视图控制器传递到选项卡栏? - how to pass image from view controller to tab bar with segue? 如何更改一个视图控制器的选项卡栏的颜色? - How do I change the color of the tab bar for one view controller? 选择到标签栏控制器 - Segue to Tab Bar Controller 从Table View控制器到Tab Bar控制器的Segue - Segue from Table View controller to Tab Bar Controller 迅速,选择从标签栏控制器中拆分视图控制器 - Swift, segue to split View Controller from Tab Bar Controller 如何将图像视图从视图控制器传递到选项卡式视图控制器而无需保持链接 - How to pass image view from view controller to tab bar view controller without segue? 如何从第一个选项卡中切换到标签栏控制器的第二个选项卡? - How can I segue to the second tab of a tab bar controller from the first tab? 单击第一个视图控制器中的按钮时如何通过选项卡栏控制器从一个视图控制器转到另一个视图控制器 - How to go from one view controller to another view controller through tab bar controller when Click a button in the first view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM