lassvi lassvi - 4 months ago 12
Swift Question

Changing view controller to tab bar controller

I have a tab based application with 2 tabs ( HomeViewController and SettingsViewController)

On the SettingsViewController i have a button that will take the user to a third view (ChangeSomeSettingController).

On that third view i have a TableView with this function

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let settingsViewController = self.storyboard!.instantiateViewControllerWithIdentifier("SettingsViewController") as! SettingsViewController
self.presentViewController(settingsViewController, animated:true, completion:nil)

This will move the user back to the SettingsViewController, however am not able to get the tab bar to display at the bottom of the screen like it is when am first loading the application.

How can i go back to the SettingsViewController and keep the tabs at the bottom of the screen.


First of all, presentViewController:animated:completion: will present SettingsViewController modally. What you need is a UINavigationController flow.

1) Add create UITabBarController enter image description here

2) Select the item(UIViewController) that will has a UINavigationControler flow.

3) Delete it

4) Add UITableViewController

5) Add the new UITableViewController to the UITabBarController enter image description here

6) Select the UITableViewController and embed in(Editor > Embed In > Navigation Controller) to a Navigation Controller. enter image description here

7) Add a UIViewController and add a segue(Show) between UITableViewController and UIViewController

8) The result final result should be something like this: enter image description here