Search code examples
iosswiftuser-interfaceuinavigationcontrolleruisplitviewcontroller

Navigation Controllers disappearing in UISplitViewController


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?


Solution

  • 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