Switch from View Controller to Tab Bar Controller in a Storyboard xCode

I am working on an app in xCode 5. This is a first at using the Storyboard. My app starts with a simple username/password login screen. Upon successful login, I want to programmatically switch from this login View to my Tab Bar Controller with the tab index set at 1.

I do not have a custom class for my UITabBarController. I can build one if need be. Can someone help get me started or point me in the right direction?

Answers


Funny how typing out the question can help you solve it. Here is the code I used in case someone has the same issue in the future

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
    UITabBarController *vc = (UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"UITabBarController"];

    [self presentViewController:vc animated:YES completion:nil];
    [vc release];

If you have only one storyBoard in your project then you can also use simply

self.storyboard

The best way to do this is to set your rootviewController to tabBarcontroller as soon as you authenticate the user. Here is how you can do this in swift.

let tabBarController = self.storyboard?.instantiateViewControllerWithIdentifier("TabBarController") as! UITabBarController
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = tabBarController

Where TabBarController is the storyboard id of your tab bar controller. It could be anything whatever name you have given it.


In storyboard; drag a segue from your ViewControllers button (or File's Owner to connect a method) to your TabBarVC. Choose modal style and animation if you wish.

Add a new custom class for UITabBarController and assign it to TabBarVC in storyboard. In it's implementation file; put self.selectedIndex = 1;


Need Your Help

How do I use Google Custom Search with Drupal without installing a module?

drupal search search-engine

I'd like a more capable search for my website. My current search is unable to ignore spelling mistakes and since our site is a multi lingual we really need this capability. Google has a great way of

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.