0

I have ViewController (VC_1) that is embedded in NavigationController. In VC_1 there is TableView with cells and there is segue from each cell to ViewController with detailed info (VC_2).

So when I touch any cell in VC_1 I get VC_2 with navigation bar and back button.

What if I have separate ViewController VC_3 that is not inside NavigationController. It also has cells with segue to VC_2 with same identifier that VC_1's cell have. When I get to VC_2 from VC_3 I don't see navigation bar with back button. What are the ways to handle it?

enter image description here

moonvader
  • 19,761
  • 18
  • 67
  • 116
  • **When I get to VC_2 from VC_3 I don't see navigation bar with back button.** how u r presenting/displaying the from VC2 to VC3 – Kumar KL Jan 31 '17 at 13:46
  • I can open VC_3 from VC_1 and after this I have segue from each cell to VC_2 (kind = Show Detail (e.g. Replace)) – moonvader Jan 31 '17 at 13:48
  • You shouldn't have to give each VC its own Navigation Controller. Either you're not using the root VC's Navigation Controller to present the other VCs, or you're embedding each VC in its own Navigation Controller. Please show us some code, so we can figure out which. – dylanthelion Jan 31 '17 at 13:49
  • I added image to question - black circle is button that opens VC_3 from VC_1 with Show (e.g. Push) segue – moonvader Jan 31 '17 at 13:55

4 Answers4

1

You can place another navigation controller right behind the (VC_3)

Hope this was helpful :)

Saeed Hajizade
  • 325
  • 1
  • 4
  • 21
  • but what if i want that there will be Navigation Bar in VC_2 in every case? – moonvader Jan 31 '17 at 15:07
  • sorry i misunderstood your question at first then i read it again and i edited my answer. I don't understand how your (VC_3) is NOT in your Navigation controller but i think even if its out of navigation controller , you can put another Navigation controller right behind the (VC_3) – Saeed Hajizade Jan 31 '17 at 15:42
0

If you show VC_3 from VC_1 with Show (e.g. Push) segue the Navigation Bar must appear in the VC_3.

What if I have separate ViewController VC_3 that is not inside NavigationController.

From here I understand that you don't want a Navigation Bar on VC_3. So, you can hide the navigation bar in the viewWillAppear of VC3 and show it again in the viewWillDissappear like in this answer:

How to hide a navigation bar from first ViewController in Swift?

Then, if you do the segue from VC_3 to VC_2 with Show (e.g. Push) you will have the Navigation on VC_2 with no problems.

If after this it still not working, check that you are creating well the cell in VC_3 using the dequeueReusableCell withIdentifier method.

Community
  • 1
  • 1
Jaumefm17
  • 126
  • 9
  • I want NavigationBar to be visible in VC_2 every time. And I do have problems with navigation bar when I make segue from VC_3 to VC_2 – moonvader Jan 31 '17 at 18:09
  • Are you hiding the navigation bar of VC_3 from the storyboard? If the push from VC_1 to VC_3 is correct the Navigation Bar must appear on the storyboard. – Jaumefm17 Feb 01 '17 at 07:08
0

Add in a new navigation controller to your story board. Now, change the segues like this:

Vc_1 -> new navigation controller --> vc_3

If tat doesn't make sense this is what i mean, change the segue that is currently going from vc1 to vc3 and make it go to a new navigation controller and then connect that navigation controller and make vc3 its root view controller.

Timmy
  • 537
  • 3
  • 10
0

Try putting this in the problematic VC:

 override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.setNavigationBarHidden(false, animated: false)
    }

And make sure the segues are using push. :)