简体   繁体   中英

How remove UITabBarController from UIViewController

当我们使用UINavigationController从一个UIViewController移到另一个UIViewController时,如何从UIViewController删除UITabBarController

Overwrite the init function in your code ( loadView probably won't work )

self.hidesBottomBarWhenPushed = NO;

// OR you can remove it from app delegate by putting these lines in a method named by urself

[mainMenuTabBarController.view removeFromSuperview];

You should set this property of UIViewController to YES: BOOL hidesBottomBarWhenPushed

Example: The second line of the code below is what you ask.

UIViewController *destinationVC = [[UIViewController alloc] init];
[destinationVC setHidesBottomBarWhenPushed:YES]; // !!!
[self.navigationController pushViewController:destinationVC animated:YES];
[self.tabBarcontroller.view removeFromSuperview];
[self.tabBarcontroller.view removeFromSuperview];
[self.tabBarcontroller.tabbar removeFromSuperview];
UIViewController *yourController = [[UIViewController alloc] init];
[yourController setHidesBottomBarWhenPushed:YES]; 
[self.navigationController pushViewController:yourController animated:YES];

here you make a instance of your ViewController and then befor pushing it just use the setHidesBottomBarPushed() so that it is hidden when you push it.

But remember it will work only if u do this befor pushing.

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