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?
You can place another navigation controller
right behind the (VC_3)
Hope this was helpful :)
If you show VC_3 from VC_1 with Show (eg 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 (eg 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.
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.
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. :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.