带有标签栏的presentViewController [英] presentViewController with the tabbar

查看:34
本文介绍了带有标签栏的presentViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它有一个标签栏,它出现在大多数 ViewControllers 中.问题是它没有显示在我通过此代码呈现的 viewController 中.

I have a app which has a tabbar which is presented in most of the ViewControllers. The problem is its not showing in an viewController which i'm presenting by this code.

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:songsViewController];
[self presentViewController:navigationController animated:YES completion:nil]

我正在使用 presentViewController 而不是 pushViewcontroller,因为我想在此视图中自定义 navigationBar.

I'm using the presentViewController instead of the pushViewcontroller, cause i want to customize the navigationBar in this view.

如何展示我使用 storyboard 创建的标准标签栏?

How can i present my standard tabbar which i've created using storyboard?

推荐答案

当您使用 presentViewController:animated:completion 时,您是以模态方式呈现视图控制器,这意味着它不包含在任何你现有的容器,比如 UITabBarController 或类似的东西.因此,如果您希望在以模态方式呈现 UIViewController 时显示某些内容,则它必须包含在您以模态方式呈现的视图控制器中.因此,从它的外观来看,您只是呈现一个 UINavigationController,其中包含您的 songsViewController.如果你想保持你的 UITabBar 显示,要么你需要在你呈现的视图中添加一个,要么你需要更改你的代码,这样你就不会在此处以模态方式呈现视图控制器.并为与您已经呈现的 UITabBar 匹配的模态视图添加第二个 UITabBar,这会使您的应用程序运行得相当奇怪,所以我建议尝试更改它使您根本不必呈现模态视图.

When you use presentViewController:animated:completion, you are presenting the view controller modally, meaning it is not being contained within any of your existing containers like a UITabBarController or anything like that. So if you want something to show up when you present a UIViewController modally, it must be contained within the view controller that you're modally presenting. So from the looks of it, you're simply presenting a UINavigationController with your songsViewController contained within it. If you want to keep your UITabBar showing, either you need to add one to the view you're presenting, or you need to change your code so that you're not presenting a view controller modally here. And to add a second UITabBar for the modal view that matches the UITabBar that you were already presenting, it will make your app work rather strangely, so I would suggest trying to change it so you're not having to present a modal view at all.

这篇关于带有标签栏的presentViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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