title: How to fix disappearing Tab Bar Controller when changing View Controller initialized from code
body: <p>I'm struggling with the problem which is when I'm switching view controllers connected with push segue then everything works as expected. The problem is that I have a search bar that executes Table View Controller from code and when I select the cell from that Table View Controller the next view controller is without tab bar.  </p>
  
  <p>I am using Table View Controller as a view that displays results from search bar. When I am selecting cell (result from searching) then I am changing view controller showing the results. But this one is done from storyboard. 
  I know that the Table View Controller executed from code does not "inherits" tab bar from previous controllers through the navigation bar. But this one should be executed from code.</p>
  
  <blockquote>
    Initialize Search Result Controller
  </blockquote>
  
  <pre><code> override func viewDidLoad() {
      super.viewDidLoad()
      self.definesPresentationContext = true
  
      tableView.separatorStyle = .none
      self.extendedLayoutIncludesOpaqueBars = true
      refreshControlUI = Refresher.configureRefresher()
      tableView.refreshControl = refreshControlUI
      refreshControlUI.addTarget(self, action: #selector(pullToRefresh), for: .valueChanged)
  
  
      // Initialize search table
      let priceSearchTable = storyboard?.instantiateViewController(withIdentifier: "CoinSearchTable") as! CoinSearchTableViewController
  
      // asignle pricetable as a search results controller
      resultSearchController = UISearchController(searchResultsController: priceSearchTable)
      resultSearchController?.searchResultsUpdater = priceSearchTable
  
      // Make navigation bar large
      self.navigationController?.navigationBar.prefersLargeTitles = true
      self.navigationController?.navigationItem.largeTitleDisplayMode = .never
      self.navigationItem.searchController = resultSearchController
  
      // customize search bar
      let searchBar = resultSearchController!.searchBar
      searchBar.sizeToFit()
      searchBar.placeholder = "Search for coins"
  
      resultSearchController?.hidesNavigationBarDuringPresentation = false
      resultSearchController?.dimsBackgroundDuringPresentation = true
  
  
   }
  </code></pre>
  
  <blockquote>
    This code is responsible just for passing values to selected view controller.
  </blockquote>
  
  <pre><code> override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  
      if shownAllCoins.count &gt; 0 {
  
              let coinString = shownAllCoins[indexPath.row]
              picked = PickedCoin(symbols: [coinString])
              picked.delegate = self
              navigationController?.setNavigationBarHidden(false, animated: true)
              picked.getDetail(name: coinString)
              coin = picked.coins[0]
      }
  
  }
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  
      if segue.identifier == "goToDetailsFromSearch" {
          if let coin = sender as? [Any]{
              if let SearchVC = segue.destination as? DetailPriceViewController{
  
                  SearchVC.coin = coin[0] as? Coin
                  SearchVC.isFromSearching = coin[1] as! Bool
              }
          }
  
      }
  }
  </code></pre>
  
  <p>Also In Detail View Controller I had to create navigation bar programmatically in case if the segue was from the Search Result Controller. </p>
  
  <pre><code>func addNavBar() {
  
          view.backgroundColor = UIColor(hex: 0x001f3e)
  
          let navBar: UINavigationBar = UINavigationBar(frame: CGRect(x: 0, y: 20, width: view.frame.size.width, height: 44))
          navBar.barTintColor = UIColor(hex: 0x001f3e)
          navBar.isTranslucent = false
          self.view.addSubview(navBar);
          guard let coin = coin else {return}
          let navItem = UINavigationItem(title: "\(coin.symbol)")
  
          let backButton = UIButton(type: .custom)
          let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
          navBar.titleTextAttributes = textAttributes
  
          saveButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.bookmarks, target: self, action: #selector(self.selectorName(_ :)));
  
  
          backButton.setTitle("Back", for: .normal)
          backButton.setTitleColor(backButton.tintColor, for: .normal) // You can change the TitleColor
          backButton.addTarget(self, action: #selector(self.backAction(_:)), for: .touchUpInside)
  
          navItem.leftBarButtonItem = UIBarButtonItem(customView: backButton)
          navItem.rightBarButtonItem = saveButton
  
          navBar.setItems([navItem], animated: false)
      }
  </code></pre>
  
  <p>Bellow is screenshot of storyboard connection. This storyboard without navigation bar is of course this <code>SearchResultController</code> (Table View Controller that displays results and switches to the detail controller).</p>
  
  <p><img src="https://user-images.githubusercontent.com/18743955/51631748-c637cf80-1f4d-11e9-8814-13df58e63e0d.png" alt="storyboard" title="storyboard"> 
  <img src="https://user-images.githubusercontent.com/18743955/51631998-82919580-1f4e-11e9-924f-791b3c30c8be.png" alt="expected" title="expected"> 
  <img src="https://user-images.githubusercontent.com/18743955/51631979-74437980-1f4e-11e9-89b8-b30db5ddf670.png" alt="failed" title="failed"> 
  What is the best way to set tab bar as a root controller or something. I just need the tab bar to be in all view controller doesn't matter if the controllers are initialize from storyboard or code.</p>
  
  <p>I am trying all day to fix this but I don't know how.. 
  I appreciate every help!</p>
  
  <p>Thanks! </p>