Search code examples
iosswiftuitabbarcontrollerpushviewcontroller

Manage the PushViewController With Tabbar


I have TabBar Embed-in in SecondViewController I have a tableview i want to push ViewController with the with Didselect And also back to the secondViewController with navigation Back Button.

StoryBoardSetup

enter image description here


Solution

  • You can create segues to navigation controllers for each transition you want with unique identifiers in storyboard.

    Then you can call the transition manually in didSelect with performSegue:

    self.performSegue(withIdentifier: "Identifier", sender: self)
    

    And because you embed your views in navigation controller you don't need to handle back button, it handles automatically.

    Also you can set the next view controller properties by overriding the perepareForSegue:

    override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
        if (segue.identifier == "Identifier") {
           let destination = segue.destination as! YourViewController
           // pass data to next view
        }
    }