Instead of using two navigation controllers you can use a single NavC and then make your view controller with the two buttons as the root view controller. Then when the buttons are pressed you load the appropriate table view controller. Also if your table view controller has the same data source then you can use a single table view controller itself.
Then depending on which button is pressed you push the appropriate table view controller but in the prepareForSegue
keep track of which button was pressed so that you can change its title when a cell is selected in the table view controller.
To pass the selected cell details from the table view controller you can make use of a delegate which your view controller can implement and the table view controller will call and pass the selected cell details.
So in short do this.
- Make your navC as the initial view controller.
- Make your view controller with the two buttons as the root view controller of the navC
- In the IBAction of the two buttons store which button was pressed so that you will know which buttons's title has to be changed.
- When you load table view controller set the view controller as a custom delegate.
- In the language list table view controller's
didSelectRowWithIndexPath
use the delegate to pass the selected cell info and pop the view controller.
- In the delegate method of the view controller change the button title that you have stored in step 3 to the selected cell's text.
I have another solution which I have uploaded here. It does not contain any custom view controllers except the ViewController that has the two buttons. It makes use of segues and unwind segues.
http://www.filedropper.com/twobuttonnavc