0
votes

I have a menu, which is just a tableview on a tab. When you select one of the table cells it segues to a viewcontroller that is embedded in a navigation controller. i have added a 'Done' button to this navigation controller and created a segue back to the menu. however now the menu doesn't show the tabBar and it now shows a navigation bar with a 'Back" button on it.

This is the menu (part of tab bar) just a table view

enter image description here

This is the pages shown when clicking tableview cell

enter image description here

This is the menu again after clicking 'Done'

enter image description here

when clicking done i wanted it to go back to the menu as it was shown in the first screenshot. i was trying to use the interface builder for this but guess i could create a class and go back to the menu via code.

Any ideas how to fix this?

----- EDIT -----

This is support page without 'Done' button

enter image description here

------ EDIT -----

this is the flow layout, sorry its messy working on small screen laptop atm

enter image description here

2
for displaying the SUPPORT PAGE, are you displaying it using pushviewcontroller or presentviewcontroller? - jo3birdtalk
i am using push segue - Pippo
if you don't setup the Done button, are you seeing the back button? Do you see a navigation bar? - jo3birdtalk
i can see the navigation controller but there is no default back button, i added a screenshot to the bottom of the main question. - Pippo
remove the bottom right navigation controller, it isn't needed as it is already in a navigation controller stack - Matthew Cawley

2 Answers

1
votes

I just realised you did not have a Navigation bar on your Menu Tab. All you need to do is embed in a navigation controller. Let me know if it does not work.

enter image description here

override  func tableView(_ tableView: UITableView, didSelectRowAt
 indexPath: IndexPath){
    if(indexPath.row == THE_ROWNUMBER_OF_YOUR_SUPPORT_PAGE){
        let displaySupportPage = self.storyboard?.instantiateViewController(withIdentifier: "SuppportPage") as! ChooseSalonTVC
        self.navigationController?.pushViewController(displaySupportPage, animated: true)
    }

 }

enter image description here

Check "Hide Bottom Bar On Push"

1
votes

You should use the "Show (e.g. Push)" segue and not "Push". This allows it to show itself correctly in the stack.

Using "Push" requires that the existing screen exists inside a navigation controller, which it doesn't on the first load. By using "Push" it is moving the controller into a navigation controller stack which leaves you with the navigation bar after pressing done.

By using the "Show (e.g. Push)" segue option, the system will chose to use a modal presentation or a navigation controller push based on your current view hierarchy.

Show (e.g. Push):

enter image description here

Note: if your view is shown using a Model presentation you need to use

[self dismissViewControllerAnimated:YES completion:nil]; 

and not

[self.navigationController popViewControllerAnimated:YES]; 

You can do a quick check to choose the correct method:

if (self.navigationController) {
    [self.navigationController popViewControllerAnimated:YES];
}
else {
    [self dismissViewControllerAnimated:YES completion:nil];
}

This will allow you to show the screen in multiple ways without having to do any additional checks