0
votes

I have an app that is two view controllers connected via a tab bar controller. The first view is a tableView cell and the second is several labels that are connected.

Currently my code works so that when I select a cell in the table view, it brings up the associated information from the second view controller. However, to get back to the first view controller, I currently have a back button.

How do I make it so the tab bar controller buttons don't disappear when the cell is tapped, so that I can quickly and more seamlessly jump between the two view controllers?

Relevant code for selecting a cell:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
    x = indexPath.row
    y = indexPath.row
    z = indexPath.row
    performSegue(withIdentifier: "seque", sender: self)
}

And then I call this in the viewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()

            xLabel.text = wordList[x]
            yLabel.text = wordDefinition[y]
            zLabel.text = wordSnippet[z]
1
add code , screenshots and elaborateSh_Khan
do you have a tabbarcontroller and a navigationcontroller at the same time?luk2302
@luk2302 just the tabbarcontroller I think.alnair
What segue type are you using ? If modal change it to showRoma

1 Answers

0
votes

If I understand this correctly, you need to have your first VC embedded into a NavigationController and the Navigation Controller embedded into a TabBarController.

This way, when you drag a segue from your first VC to your second VC, the second VC will also be embedded into the same Navigation Controller.

And since the Navigation Controller is inside a TabBar Controller, the second VC will also be embedded into the same TabBar Controller.

You will end up with something like this:

enter image description here

As you can see, all VCs retain the TabBar and the Navigation Bar.

And you can do this by selecting the desired VC and then from Editor menu > Embed in.