Pushed over tabs

Hi,
I am making an app and I am using tab navigation controller and the navigation controller, and whenever I push into another view controller through a segue, if I go to a different tab, then back to that one it's still on the pushed to view controller. Ideas on how to fix this.

Thanks in advance!
Answered by OOPer in 666010022

Ok, I have other view controllers that don't have any code connected to them. The only other part of code is loading a form. All the code I have is there.

I see. There may be some superhero who can read your mind and give you an example. Good luck.

 I am using tab navigation controller 

I guess it is tab bar controller, if not, please tell us.

What you have described is the usual behavior when you embed navigation controller inside any of the tab content.
If you want to make what you wrote, you need to write some code to pop back the navigation controller.

Typically, you make some class conform to UITabBarControllerDelegate and implement tabBarController(_:didSelect:).
Could you give an example?

Could you give an example?

Without your code it is hard.
Here you go:

Code Block
import UIKit
class Categories: UIViewController {
    @IBOutlet weak var CategoryList: UITableView!
    
    let names = [
        "Dad Jokes",
        "Virtual Assistant Jokes",
        "Knock Knock Jokes"
    ]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        CategoryList.delegate = self
        CategoryList.dataSource = self
    }
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let backItem = UIBarButtonItem()
        backItem.title = "Back"
        navigationItem.backBarButtonItem = backItem // This will show in the next view controller being pushed
    }}
extension Categories: UITableViewDelegate {
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print(indexPath.row)
        let row = indexPath.row
        if row == 0 {
            self.performSegue(withIdentifier: "Dad Jokes", sender: self)
        }else if row == 1 {
            self.performSegue(withIdentifier: "Assistant Jokes", sender: self)
        }else if row == 2 {
            self.performSegue(withIdentifier: "Knock Knock Jokes", sender: self)
        }
        tableView.deselectRow(at: indexPath, animated: true)}
}
extension Categories: UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return names.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
        
        cell.textLabel?.text = names[indexPath.row]
        
        return cell
    }
}


Here you go:

It does not make sense shown only one view controller. You say you use tab bar controller and navigation controller.
You have at least 3 view controllers, two for tab bar controller, and one for pushed in navigation controller.
would you like the rest of the code, the project or a screenshot of the storyboard?

would you like the rest of the code, the project or a screenshot of the storyboard?

Any info that helps to write an example. You are not any more a beginner here in the dev forums. Please think yourself what is needed to write an answer best fit for you.
Ok, I have other view controllers that don't have any code connected to them. The only other part of code is loading a form. All the code I have is there.
Accepted Answer

Ok, I have other view controllers that don't have any code connected to them. The only other part of code is loading a form. All the code I have is there.

I see. There may be some superhero who can read your mind and give you an example. Good luck.
You should better not mark non-solution answers as SOLVED.

Please read the support page of the dev forums.
(If already read once, then again more carefully.)


One more, SOLVED threads would not get much attention. You should better start a refreshed new thread. Please do not forget to include as much info as you can show.
I meant to do the first, i made a mistake.
Pushed over tabs
 
 
Q