如何从UIViewController中删除UITabBarController



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

覆盖代码中的init函数(loadView可能不起作用(

self.hidesBottomBarWhenPushed = NO;

//或者,您可以通过将这些行放在由urself 命名的方法中,将其从应用程序委托中删除

[mainMenuTabBarController.view removeFromSuperview];

您应该将UIViewController的此属性设置为YES:BOOL hidesBottomBarWhenPushed

示例:下面代码的第二行是您所要求的。

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

在这里,你制作了一个ViewController的实例,然后在推送它之前,只需使用setHidsBottomBarPushed((,这样当你推送它时它就会被隐藏。

但请记住,只有在推之前这样做,它才会起作用。

最新更新