Easy Tutorial
❮ Att Ios Ui Scrollview Ios Maps ❯

Usage of iOS Tab Bar

It is commonly used to switch between various sub-tasks, views, or models within the same view.

An example of a tab bar is shown below:

Important Properties

Example Code and Steps

  1. Create a new project, select Tabbed Application instead of a single view application, click next, enter the project name, and select create.

  2. Two view controllers and a tab bar are created by default and added to our application.

  3. The AppDelegate.m didFinishLaunchingWithOptions method is as follows:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
        UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
        self.tabBarController = [[UITabBarController alloc] init];
        self.tabBarController.viewControllers = @[viewController1, viewController2];
        self.window.rootViewController = self.tabBarController;
        [self.window makeKeyAndVisible];
        return YES;
    }
    
  4. Two view controllers are used to assign as the tab bar controller's view controllers.

  5. Run the application to get the following result:

❮ Att Ios Ui Scrollview Ios Maps ❯