I have a Tab Bar Controller that has a navigationcontroller with a view controller attached. For some unknown reason the navigation bar of the view controller does not look like it always does. Instead the view controller's navigation bar is added below the navigation controller's.
When I look at the view controllers embedded in the first navigation controller before the Tab Bar Controller is shown, it works as expected.
This it what it should look like
And this
Now when I segue to the Tab Bar Controller which has a new navigation controller with a view controller embedded it looks like this:
I don't want an additional navigation bar below the one provided by the navigation controller. I want the title and the item of the view controller merged with the navigation controller. So the final result should display a row with the back button, the title and the bar button item(Search Image)
What am I missing?
I've also tried adding the navigation items programmatically but nothing seemed to work.
My Code
//
// SideViewController.swift
// Sample
//
// Created by on 08.02.20.
// Copyright © 2020 . All rights reserved.
//
import UIKit
class SideViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "Search"
}
@objc func action(){
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
There is two ways that I found you can resolve this either by presenting tab bar controller modally or hiding navigation bar of a tab bar controller when view loads.
First solution can be achieved like this:
And second solution can be achieved like this:
viewDidLoad()
paste this navigationController?.navigationBar.isHidden = true
in order to hide current navigation bar.Remember to make just one of this two solutions. Which one would it be is up to your needs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.