Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the tab bar disappearing?

My current setup of viewcontrollers are: tab view > navigation controller > table view controller > navigation view controller > cell details. Please see The current setup of viewcontrollers

I used to have: tab view > navigation controller > table view controller > cell details and then everything was fine.

The issue is that I need a custom action to happen when the user presses the back button, and to do this i added a nav controller between the "table view" and the "cell details". And thats when the tab bar disappeared. I understand this seems to be "normal" behaviour, but that don´t help me much. Please help.

The code that segues to the detail view controller. (I use the storyboard, so light on code for these things)

@IBAction func add(sender: AnyObject) {
    dispatch_async(dispatch_get_main_queue()) {
        self.performSegueWithIdentifier("TableViewToDetailView",    sender: self)
    }
like image 252
LudoErgoSum Avatar asked Feb 07 '23 02:02

LudoErgoSum


2 Answers

It happens when hideTabBarOnPush property is true(in code) or Hide Bottom Bar on Push is checked on storyboard for the controller you are pushing.

enter image description here

like image 119
Sahil Kapoor Avatar answered Feb 13 '23 06:02

Sahil Kapoor


I had a similar problem and the right question was kind of hard to ask. using Tsb Bar Controllers with Navigation Controllers and View Controllers os too tricky and certain things a re not allowed and there is a lot of terminology, and, there are many different types of segues,and there are many different kinds of consequences for doing certain things.

I found the correct procedure (answer) in the second part of this two part series:

  1. Storyboards Tutorial for iOS: Part 1
  2. Storyboards Tutorial for iOS: Part 2

Summary of the procedure: Embed the source and destination View Controllers in Navigation Controllers, then create unwind segues (methods with the signature@IBAction func methodname(_ segue:)) in the source view controller. Then, from the destination View Controller, control-click from the navigation bar button (or any view required to trigger a return to the first view controller) to the Exit object above the view controller then pick the correct action name from the popup menu. The unwind segue will be accessible from the Document Outline and can be given an identifier to use in prepare(for:sender:) in case data needs to be sent to the from the destination view controller. Also, the segue from the first view Controller to the second navigation controller must be modal.

like image 24
nyxee Avatar answered Feb 13 '23 06:02

nyxee