D. Murphy D. Murphy - 1 month ago 18
iOS Question

Tab Bar Controller Disapering When Moving Back To Another View

I want to create an app that lets the user click on a button on V1 on the navigation bar. This will segue to V2 where they can press another button on the navigation bar on V2 and it will bring them back to V1 which has the tab bar controller at the bottom. I don't want the tab bar on V2 and I don't want V2 as a tab bar item. When I try this the tab bar disappers on V1 when I segue back to V1 from V2.

TAB BAR CONTROLLER -> TAB BAR ITEM (V1) -> V2(Via navigation bar button item on V1) -> back to V1(Via navigation bar button item on V2)

I have added

[self.navigationController, popViewControllerAnimated:YES];
to my button function but it comes up with an error - expected expression in container literal.

Apart from this code I have not got any other code in my app yet.

I am using Xcode 8.0 and Swift 3.0

Answer

I have solved my problem after days of trying to figure out an answer. You need to add this to any view controller.

@IBAction func unwindToViewController (sender: UIStoryboardSegue){

    }

Then you can add a segue from bar button item to the exit icon on the view controller.

You can view an image of the VC scene here.