LudoErgoSum
LudoErgoSum

Reputation: 73

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)
    }

Upvotes: 4

Views: 4480

Answers (3)

nyxee
nyxee

Reputation: 2811

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.

Upvotes: 1

Zhengqian Kuang
Zhengqian Kuang

Reputation: 1109

A similar issue I met although maybe not quite the same as yours but hope it may help. When view controller A presents view controller B, the hidesBottomBarWhenPushed property of B could be overridden by the hidesBottomBarWhenPushed property of A. I fixed it by setting B's modal style.

Upvotes: 0

Sahil Kapoor
Sahil Kapoor

Reputation: 11773

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

Upvotes: 7

Related Questions