如何在标签栏控制器中从一个视图控制器切换到另一个视图控制器并保留标签栏? [英] How within a tab bar controller do I segue from one view controller to another and retain the tab bar?

查看:103
本文介绍了如何在标签栏控制器中从一个视图控制器切换到另一个视图控制器并保留标签栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有多个视图控制器的应用程序,它们是通过标签栏控制器控制的从我想要的其中一个视图控制器(点击一个按钮)转到另一个视图控制器并保留要查看的segued底部的标签栏。

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.

I已使用

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

这项工作正常,但标签栏中缺少标签栏segued to view(占位符在故事板中显示,但在应用程序运行时不显示)
我也尝试更换

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];

但这也不起作用。

一些调试显示,对于segued-to视图控制器,tabBarController属性设置为nil。

A bit of debugging shows that for the segued-to view controller, the tabBarController property is set to nil.

无论如何都要保留标签栏中的标签栏 - 查看控制器?

Is there anyway to retain the tab bar in the segued-to view controller?

推荐答案

从您的解释来看,我认为您不需要模态控制器。 Modal用于叠加,使标签栏无效。从你的故事板中,选择你的segue并选择推送,而不是模态。

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.

推送与模态(注意标签栏):

Push vs Modal (Note the tab bar):

< img src =https://i.stack.imgur.com/AOvEg.pngalt =在此输入图像说明>

这篇关于如何在标签栏控制器中从一个视图控制器切换到另一个视图控制器并保留标签栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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