Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - How do I segue from ViewController to TabBarController

How do I add a ViewController before a TabBarController in Swift? I am using Parse to make a custom login in the ViewController which would lead to the TabBarController... Help would be appreciated!

like image 661
davidgilman Avatar asked May 24 '15 00:05

davidgilman


2 Answers

1. Control-drag from yellow symbol (ViewController) to the TabBarController

enter image description here


This will create a segue in your ViewController menu

enter image description here


2. Click this new segue "Show segue to Tab..." and in identity inspector set an identifier name.

enter image description here


3. Now when you want to make the segue happen, use call...

performSegueWithIdentifier("WhatEveryYouNamedSegue", self)
like image 139
Chameleon Avatar answered Jan 03 '23 18:01

Chameleon


This is the way I transfer from the login view controller to my home view controller tab bar.

let homeViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeVCTabBar") as? UITabBarController

            self.view.window?.rootViewController = homeViewController
            self.view.window?.makeKeyAndVisible()

The most common mistake people make is that they use Instead of UITabBarController the name of the VC they go to.

Make sure you use UITabBarController to entry the first view from your TabBarController.

like image 31
JustinvR Avatar answered Jan 03 '23 18:01

JustinvR