Hide UITabbar and show Toolbar on show segue - ios

on my xcode project i have a Table View Controller inside of a Navigation Controller inside of a Tab Bar Controller
(Tab Bar -> Navigation Controller -> Table View Controller)
When a Table View Cell selected show segue launches with a new Table View Controller.
What I want to achieve is to hide Tab Bar Controller and show Toolbar Controller inside the new view (Just like the behaviour in Whatsapp's Chats screen).
I am able to hide Tab Bar with hidesBottomBarWhenPushed=true in prepareForSegue but failed to show Toolbar. How can i achieve this behaviour?

I have fixed the issue with setToolbarHidden method in viewDidLoad():
self.navigationController?.setToolbarHidden(false, animated: true)

Related

Tab bar not visible on coming back to selected item

I am facing a strange issue with Tab bar controller. I have a tab bar controller in main.storyboard working fine. I have 5 different storyboard references for each item and I could see all 5 tabs and tab bar is working fine in the simulator.
On selecting the 3rd tab, there is a button in 1st view controller that pushes to second view controller, here I am hiding the tab bar in viewWillAppear. Then when I push to 3rd view controller, I am showing the tab bar again in viewWillAppear.
Now when I select some other tab item from 3rd view controller and come back to 3rd tab, tab bar is not visible even though i have written below code:
override func viewWillAppear(_ animated: Bool) {
tabBarController?.tabBar.isHidden = false
}
Finally figured out the issue. One of my view controller in storyboard had hide tab bar on push view controller enabled causing the tab bar to hide in my expected view controller. On unchecking it and handling all hide/show tab bar in source code itself, i am able to fix the issue.

Change View Controller in Tab Bar Controller (Swift)

A little background: My app pops a View Controller that has questions. When the person has answered the question, they swipe and View Controller is presented again, this time with new questions (so it is View Controller with question set 1 -> swipe -> (same) View Controller with question set 2).
This works fine when I do not have View Controller embedded in a Tab Bar Controller. However, when it is embedded in a Tab Bar Controller and I swipe, the View Controller is presented but the Tab Bar Controller is no longer there.
I want the tab bar to remain at the bottom of the screen but I want the View Controller to change upon swiping
func swipeGesture() {
// gesture stuff in here
self.present(ViewController(), animated: true)
}
In Tabbar Controller put a navigation controller. Above the same you can push as much as view controllers of same type or that of different types.
It will work.

Navigation controller back button doesnt appear?

I'm trying to setup back button on the navigation controller but it doesn't appear when I run it. I watched some tutorials and it usually works.
Your flow should be:
NavigationController --> MainVC --> FoodVC
Now you can add button as follow:
Navigation Item -> Left Bar Button Items -> Bar Button Item -> back button
Go to navigation controller scene -> navigation controller ->navigation bar - then go to right top show attributes option and change bar tint color.Try it
The view controller food is embedded in Navigation Controller , hence it is root view controller.
Navigation bar will appear when any viewController is push on same navigation controller.
So, If you tableview is already in Navigationcontroller then remove Navigation Controller in which Your FoodVC Controller is embedded.
If you want that navigation controller, you may add leftBarButtonItem programatically.
Totally depends on your requirement.
Is MenuVc your main Controller? try this, delete that navigation controller in the middle. Then click the MenuVc, embed in Navigation Controller and set the navigation controller as initial view controller at the attribute inspector. then navigate the menuVC to Food, "Show".

How to load another View Controller on Tabbed application Without losing the tab

I have a Tab Bar application coded in Objective-c. One of the tabviews I have is a TableView. What I'm trying to do is, when a cell of this TableView is selected, the app takes the user to another view, but this view isn't on the tab menu, and I don't want to lose the tab menu when this view appears.
Is it possible to do it? How? Couldn't find much on the web.
Just embed navigation controller to that tab's viewcontroller which have tableview.
so your viewhierarchy should be like tabbar controller - navigation controller - viewcontroller (tab) - detailviewcontroller
you can embed navigation controller by selecting viewcontroller, then from menu select editor then embed in then navigation controller.
Hope this will help :)
If you are having the single View Controller to show then you can try doing this by adding the new view controller's view as
subView to the current view controller's view
Eg:
newVC.view.frame = self.view.frame;
newVC.view.frame.size.height = self.view.frame.size.height - HEIGHT_OF_TAB_BAR;
[self.view addSubview:newVC.view];
If there are more View Controller's that are adding further then
using the navigation controller under tab bar controller will also
work.
Refer: How to implement tab bar controller with navigation controller in right way

Show navigation bar in swrevealviewcontroller

I am using SWRevealViewController for side menu in my app. While choose one of the menu navigationbar hides automatically. I want to show the navigation bar always. I have tried following codes in my ViewController's viewDidLoad().
self.revealViewController().navigationController?.navigationBarHidden = false
and
self.navigationController?.navigationBarHidden = false
But both are not working.
I have followed https://www.youtube.com/watch?v=8EFfPT3UeWs to implement SWRevealViewController in swift based app.
Please Add a navigation controller between your sw_front navigation controller and view controller and hide the navigation bar of first navigation controller using attribute inspector.
To add navigation controller you need to select view controller and go to
Editor -> Embed In ->Navigation Controller
Your Menu (rear)VC can control this if you have it there then it always there unless you hide.

Resources