Toolbar disappear after push - ios

I have FormViewController that I made full programmatically with Eureka form builder (link). I dont have view controller in storyboard for that. Class name of that view controller is NewPasswordVC. When I click od add bar button I open NewPasswordVC with this code:
let newPasswordVC = NewPasswordVC()
self.navigationController?.pushViewController(newPasswordVC, animated: true)
I open NewPasswordVC but when I go back in root view controller my bottom toolbar disappear. Why? How to fix this?
This is storyboard:
This is my problem in gif:

Can't speak about Eureka specifically, but chances are the UIViewController being pushed in has hidesBottomBarWhenPushed set to true.
So I would look into setting it to false, which can be done programmatically.

The solution to my problem I found here: link
override func willMove(toParent parent: UIViewController?){
super.willMove(toParent: parent)
if parent == nil{
self.navigationController?.isToolbarHidden = false
}
}

Related

Trying to combine a Sidemenu and a Tapbarmenu with Xcode's Storyboards

I'm trying to combine a Sidemenu and a Tapbarmenu using Xcode's Storyboards.
I took the template from here: https://johncodeos.com/how-to-create-a-side-menu-in-ios-using-swift/
Then, I modified the Home View to have a tap bar :
The first issue that I got is that I lost the SideMenu button :
.
Furthermore, you can notice that the Topbar got really thick and the View is not centered.
To fix the first issue, I tried to create a new cocoapod file for the new navigation controller in order to get the SideMenu button working again :
class MenuViewController: UITabBarController {
#IBOutlet var sideMenuBtn: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
// Menu Button Tint Color
navigationController?.navigationBar.tintColor = .white
sideMenuBtn.target = revealViewController()
sideMenuBtn.action = #selector(revealViewController()?.revealSideMenu)
}
}
I assigned the new class to the Navigation controller but the sideMenuBtn won't appear on the Sidemenu button.
I don't know if my explanations were very clear but don't hesitate to ask me for more information.
Thx,
Julien

Navigation Bar is pushed up

I am having an issue where I have a tab bar controller with 4 tabs and they each have their own navigation controller with table view controllers as root views and when the app first loads the navigation bar of the first tab is pushed up behind the status bar.
I am pretty sure this problem has something to do with constraints but I can't seem to figure out what constraints I need to change.
Code Example
class TabBarController: UITabBarController {
....
let firstNavVC = FirstNavViewController()
let secondNavVC = SecondNavViewController()
let thirdNavVC = ThirdNavViewController()
let fourthNavVC = FourthNavViewController()
self.viewControllers = [firstNavVC, secondNavVC, thirdNavVC, fourthNavVC]
...
}
class FirstNavViwController: UINavigationController {
...
let vc = TableViewController()
self.setViewControllers([vc], animated: false)
...
}
Result when app loads
How it should look
Please add self.isNavigationBarHidden = false in your FirstNavViwController and check, it should work
Remove top constraint and add top constraint to safe area layout guide.
Use self.navigationController?.navigationBar.isHidden = false this line of code in the First ViewController of each NavigationController from tabs.

Prevent UISearchBarController to show UINavigationBar

I'm using a UINavigationBar ALWAYS hidden (I'm using NavigationBar facilities to push ou pop views but I'm not showing it to final user), the problem is that in one of those views I have a tableView with UISearchBar. When I select the searchBar, make a search and click on it's "Cancel" button the NavigationBar appears, but I want to keep the Navigation hidden as it is.
I've tried to hidden the navigationBar one more time by willDismissSearchController or didDismissSearchController by
func willDismissSearchController(searchController: UISearchController) {
self.navigationController?.navigationBar.hidden = true
}
but it did not worked as I want.
Thank you in advance.
I've found a solution, so as it is a unusual question I'll reply for other people know the solution.
the following code did worked for me:
override func viewDidLayoutSubviews() {
self.navigationController?.navigationBar.hidden = true
}

Set initial viewController in Navigation controller programmatically (Layer SDK)

I want to add Layer SDK to my application (using Swift).
All view controllers here are created programmatically. Therefore I can't segue to them. I have 4 tabs in my application (UITabBarController). One of them is chat. In the chat tab I created a segue to UINavigationController. Now I want to load conversationListViewController in this UINavigationController. For that I created a class for this UINavigationController i.e. ConversationListViewController and added the following code:
class ChatNavigationViewController: UINavigationController {
var conversationListViewController: ConversationListViewController!
var layerClient: LYRClient!
override func viewDidLoad() {
let appDelegate = UIApplication.sharedApplication().delegate as!AppDelegate
self.layerClient = appDelegate.layerClient
self.conversationListViewController = ConversationListViewController(layerClient: appDelegate.layerClient)
self.conversationListViewController.displaysAvatarItem = true
self.navigationController!.pushViewController(self.conversationListViewController, animated: true)
}
}
But this is not working. And giving this kind of effect: the ConversationViewController is not loaded in UINavigationController. I am not sure if I am doing it the correct way. I'm searching for the correct way, but unable to find.
I Solved it. I dragged new NavigationViewController and added ConversationListViewController to rootviewController.I think i should try this first. Anyways thanks guys for your help.
Because you want to do this programatically:
You need to manually initialize the controller before stacking it up on the Navigation Controller. Try this:
navigationController?.pushViewController(self.conversationListViewController.init(), animated: true)

Side menu with dynamic table cell will navigate page but with navigation controller coming as nil

I have create sidemenu using this.
But the difference is only i have used dynamic UITableViewCell instead of static.
Now i face navigation issue while click on side menu item.
I have used navigation code like:
dispatch_async(dispatch_get_main_queue()) {
let propertyListing = self.storyboard?.instantiateViewControllerWithIdentifier("PropertyListing") as! PropertyListingController
self.showViewController(propertyListing as UIViewController, sender: propertyListing )
}
It will navigate the page but navigation controller will be nil after that.
What can be the issue ? Any suggestion will be most appreciate.
Rather than using a "show", you need to push the new view controller.
self.navigationController.pushViewController(propertyListing, animated: true)

Resources