Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing UIViewController above UITabBar

I have a UIViewController called ListVC. ListVC has a UITabBar that the user can switch tabs with. It also has UINavigationController.

In ListVC I have a button, that I want to push a new ViewController called DetailVC when it's pressed (with the NavigationController). I want to present DeatilVC without a UITabBar.

The problem is that when I'm using the pushViewController(animated) method, the view still has the UITabBar.

How can I push the view (I don't want to present it modally) above the UITabBar?

You can see an example of it on Whatsapp when selecting a chat from the chat list. Image:

Imafe

Code:

self.navigationController?.pushViewController(detailVC, animated: true)

Thank you!

like image 380
FS.O6 Avatar asked Sep 20 '25 08:09

FS.O6


2 Answers

Write below code when you push:

yourViewController.hidesBottomBarWhenPushed = true

You can also hide tabbar on push from storyboard also. select view controller which you are going to push and check Hide Bottom Bar on Push:

enter image description here

like image 68
iVarun Avatar answered Sep 22 '25 05:09

iVarun


Ok I've solved the problem. I had to add hidesBottomBarWhenPushed twice before and after the push code:

self.hidesBottomBarWhenPushed  = true
self.navigationController?.pushViewController(detailVC, animated: true)
self.hidesBottomBarWhenPushed = false
like image 37
FS.O6 Avatar answered Sep 22 '25 06:09

FS.O6