1

I have a slideout menu created using SWRevealViewController. Each row of the slideout menu is connected to a NavigationController. I would that two row of two different TableViewController are connected to the same ViewController with a show segue.

This is part of my Storyboard

When I navigate from the first NavigationController the ViewController work correctly and the description of the clicked cell is set in the navigation bar.

class Details: UIViewController {

var name:String = ""

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.title = name

    print(name)

}

Instead, when I navigate from the second NavigationController the ViewController doesn't work. The navigation bar is not shown, but the "name" parameter is printed.

Can anyone help me solve this problem?

4
  • Put condition in didSelectRowAtIndexPath like(if indexPth.row == 2) and navigate by coding May 5, 2017 at 10:21
  • i think you are not using PUSH , u r used Present for navigation May 5, 2017 at 10:23
  • Solved your problem or still facing same problem?
    – Krunal
    May 5, 2017 at 10:47
  • I've eliminated and recreated the show segue and the problem seems to have been resolved. In my case, is the best solution connect two different navigationcontrollers to a single viewcontroller to show details through show segue? Or should I take another solution?
    – mike5v
    May 5, 2017 at 12:16

2 Answers 2

0

You can add in your code and put index no. and title of the cell:

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{

    switch (indexPath.row)
    {
    case 2: name = "yourFirstNavigationTitleName"
        break
    case 3: name = "yourSecondNavigationTitleName"
        break
    default: break
    }

}
0

Try this and see:

override func viewDidLoad() {
    super.viewDidLoad()

    print(name)
    self.navigationItem.title = name

    if let navController = self.navigationController {
      navController.isNavigationBarHidden = false
    } else {
      print("There is no Navigation Controller. You may not be showing this controller using 'navigation push'")
    }


 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.