Search code examples
iphonetabbar

iPhone TabBar Controller Usage


I want make a typical tabbar based application.

And I want to insert login view on startup before main tabbar is shown.

I tried to insert TabbarController in main view, but cannot find appropriate code. All sample code I found is insert TabbarController on startup. (in Delegate file)

My fellow suggest create toolbar on startup but hide it at login view, but I am not sure if this is a general method or not.

In this case, what is a 'recommanded' handling method of TabbarController ?


Solution

  • A simple solution would be to

    1-Add the tab bar to UIWindow in the appDelegate as is suggested by apple.

    2-then add a UINavigationController in tabbar using tabbarController.viewControllers=[NSArray arrayWithObject:yourNavController];

    3- Now after alloc init on your login controller write this code before pushing it to the navigation controller of the tabbar yourLoginController.hidesBottomBarWhenPushed=true;

    4- push yourloginViewController to the navigation controller of the tabbar.

    5- After authentication before pushing your MainviewController instance on the navigation set it like this MainviewController .hidesBottomBarWhenPushed=false;

    I hope these five simple steps will do the magic for you cheers :) Please let me know if it helps you.Thanks