문제

I want to use UITabBarController but I do not need a tab bar because I'm going to switch tabs from the menu in another view controller. I want to remove it as it will be never used. I've created a subclass of UITabBarController and put this code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.tabBar removeFromSuperview];
}

Is that safe to remove tab bar that way?

Update: Why tab bar controller?

Apple suggests to use standard container view controllers whenever it possible. I'm trying to follow that. My screens workflow is the same as for tabs, except that they are switched by left side menu, not by the tab bar.

When I use a UIViewController and change it's child view controller I've got a lot of problems when autolayouts are not working properly.

The other reason is that I want to use story board, rather then create segues from the code so I can see my app workflow easily.

도움이 되었습니까?

해결책

When you are saying, you don't want to use it, then why to remove it. You can go with a tabbarcontroller with hidden tabbar. I am switching tabs from the bottom custom bar.

I am doing an app, which has a tababr controller with three items. Instead of using system tab, I am creating a custom view at the footer like tab & have actually set the hidden property of tabbarController's tabbar to YES.

myTabBarController.tabBar.hidden = YES;

다른 팁

Try this code

[app.navigationController.view removeFromSuperview];
[app.tabbarcontroller.view removeFromSuperview];
[app.window addSubview:app.navigationController.view];
[app.navigationController popToRootViewControllerAnimated:YES];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top