简体   繁体   English

将子视图添加到UITabBarController

[英]Add a subview to a UITabBarController

I have a UITabController and 3 UIViewController s, one for each of 3 tabs. 我有一个UITabController和3个UIViewController ,每个3个选项卡一个。

In one of these tabs, I want to add a subview (actually I want to replace the content of the tab with an other view. 在这些选项卡之一中,我想添加一个子视图(实际上,我想用另一个视图替换该选项卡的内容。

This is what I'm doing: 这就是我在做什么:

QuestionClass *oView = [[QuestionClass alloc] initWithNibName:@"QuestionClass" bundle:[NSBundle mainBundle]];
    [self presentModalViewController:oView animated:NO];

It works, but the tab bar is hidden, do you know you to show it? 它可以工作,但是标签栏是隐藏的,您知道要显示吗?

The documentation for presentModalViewController: says: presentModalViewController:的文档presentModalViewController:说:

On iPhone and iPod touch devices, the view of modalViewController is always presented full screen. 在iPhone和iPod touch设备上,modalViewController的视图始终以全屏显示。 On iPad, the presentation depends on the value in the modalPresentationStyle property. 在iPad上,演示文稿取决于modalPresentationStyle属性中的值。

If you're on an iPhone (iPod) and want your controller to stay within the tab controller's view space instead, you should look at having a navigation controller push it. 如果您使用的是iPhone(iPod),并且希望控制器停留在选项卡控制器的视图空间之内,则应考虑让导航控制器将其推入。

You can not use TabBar using Presenting view controller. 您不能使用Presenting视图控制器使用TabBar。 TabBar uses to switch the views. TabBar用于切换视图。

One of possibilities would be: 一种可能是:

Place navigationController as each tab (and corresponding viewControllers pushed for corresponding navigationController) 将navigationController作为每个选项卡放置(并为相应的navigationController推送相应的viewControllers)

Then - in necessary tab You could push next ViewController, while TabBar is still visible (and in other tabs, information doesn't change). 然后-在必要的选项卡中,您可以按下一个ViewController,而TabBar仍可见(在其他选项卡中,信息不会更改)。

Please see attached screenshot with NIB structure: 请查看附带NIB结构的屏幕截图:

在此处输入图片说明

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM