0

I currently have my app set up in a split view controller such that the details view and the master view both have navigation controllers, and the details view has recursive segues between it and another view. I use show segues, so I would figure the navigation bar would stay on top of the presented detail views. However, after activating both of the segues, the navigation bar disappears and I am left with what appears to be modal segues.

Below is a screenshot of my sample storyboard setup that reproduces the problem:

Dropbox

Here is a link to the sample project:

Any suggestions for how I can keep the Navigation Bar at the top of the views?

Brandon Slaght
  • 1,025
  • 1
  • 12
  • 34

1 Answers1

1

You need to push ViewController using of navigation controller like

   override func viewDidLoad() {
        super.viewDidLoad()
       buttonNext.addTarget(self, action: #selector(tapsOnNext), for: .touchUpInside)
    }
    func tapsOnNext(){
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "NextViewController") as? NextViewController
        self.navigationController?.pushViewController(vc!, animated: true)
    }

& in NextViewController use

   buttonPrev.addTarget(self, action: #selector(tapsOnNext), for: .touchUpInside)
    }
    func tapsOnNext(){
        self.navigationController?.popViewController(animated: true)
    }

For Next ViewController

For PrevViewController

Jack
  • 13,571
  • 6
  • 76
  • 98
  • I don't want to pop the next view controller. When the buttons are pushed, I just want to keep adding them to the stack. Similar to Twitter or Facebook, where you can view a user's profile, then click on another profile from there, and then yet another profile, and all of those are added to the view stack. – Brandon Slaght May 29 '17 at 04:35
  • Then use `self.navigationController?.pushViewController(vc!, animated: true)` But careful about navigation stacks. – Jack May 29 '17 at 04:37
  • If you mean be careful about memory, my data is hardcoded and the most levels of recursion you'll get is 3. I just wanted to reuse the storyboard view rather than making 3 dupes – Brandon Slaght May 29 '17 at 04:38
  • As you mentioned in first comment (Need only three stack) then after that use pop viewcontroller, its fine, You can go ahead. – Jack May 29 '17 at 04:41