简体   繁体   中英

Add a subview to a UITabBarController

I have a UITabController and 3 UIViewController s, one for each of 3 tabs.

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:

On iPhone and iPod touch devices, the view of modalViewController is always presented full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.

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.

You can not use TabBar using Presenting view controller. TabBar uses to switch the views.

One of possibilities would be:

Place navigationController as each tab (and corresponding viewControllers pushed for corresponding navigationController)

Then - in necessary tab You could push next ViewController, while TabBar is still visible (and in other tabs, information doesn't change).

Please see attached screenshot with NIB structure:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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