---
title: "iOS : Creating Sample on Tab Bar controller"  
description: "In this article we are going to create a sample on Tab Bar Controller...."  
author: "Tarun Kumar"  
published: 2015-08-21  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1841/ios-creating-sample-on-tab-bar-controller  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 3 minutes  

---

# iOS : Creating Sample on Tab Bar controller

Here we are going to create a sample using 'UITabBarController' class. It is a [specialized](https://yourviews.mindstick.com/audio/1209/caregivers-support-personnel-s-function-in-specialized-disability-accommodation) [view controller](https://www.mindstick.com/forum/33709/how-to-use-table-view-controller-with-small-sized-in-ios) much like the tabs in your browser where each tab represents a specific view basically the site you are visiting. Here the tabs are created at the bottom of the window and each tab is associated with a specific view controller. Each tabs view can have its own look and feel as they may represent different [functionality](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery) in [your application](https://answers.mindstick.com/qa/95487/how-do-you-troubleshoot-when-your-application-link-is-not-responding). You can even add a [navigation controller](https://www.mindstick.com/interview/22810/what-is-the-navigation-controller) [as one](https://answers.mindstick.com/qa/34642/which-indian-it-company-has-been-recognized-as-one-of-the-world-s-best-employers-by-the-top-employer-institute-for-the-third-consecutive-year) of the tab's view controller if needed. Tabbar items can be customized using image icons and specific titles.

##### Necessary steps for our sample application:

Step 1. First, create a single view application and named it TabBar.

Step 2. Associate two view [controllers](https://www.mindstick.com/forum/155773/how-asynchronous-controllers-work-in-asp-dot-net-mvc) to the tab bar controller

Step 3. Customize the look and feel of the tabs such as [background color](https://www.mindstick.com/forum/18/split-background-color), text fonts, etc.

Step 4. Set the title and image icons for the tab bar items

Step 5. After single view application created, then select File -> New -> File...

Step 6. Then, in iOS Cocoa Touch section select objective-C class and click Next.

Step 7. Give a name to the Class “Tab1ViewController” and select Subclass “UIViewController”.

Step 8. and then select create, similarly Step 7 create another objective-C class and named it

“Tab2ViewController”.

Step 9. Now, in MainStoryboard create two ViewControllers.

Step 10. except mainstoryboard, select first [ViewController](https://www.mindstick.com/forum/33628/viewcontroller-s-viewdidunload-method-deprecated-in-ios-6) and go to the Identity Inspector and select class Tab1ViewController, same as select second ViewController and in Identity Inspector select class Tab2ViewController.

\

##### Here is the Source Code of our program:

##### Tab1ViewController.h

\

```
#import <UIKit/UIKit.h>@interface Tab1ViewController : UIViewController< UITableViewDataSource, UITableViewDelegate> @end
```

##### Tab1ViewController.m

\

```
#import "Tab1ViewController.h"@interface Tab1ViewController ()@end @implementation Tab1ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.} - (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end
```

## \

##### Tab2ViewController.h

\

```
#import <UIKit/UIKit.h> @interface Tab2ViewController : UIViewController@end
```

## \

##### Tab2ViewController.m

\

```
#import "Tab2ViewController.h" @interface Tab2ViewController () @end@implementation Tab2ViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if (self) {        // Custom initialization    }    return self;}  - (void)viewDidLoad {   [super viewDidLoad];   / Do any additional setup after loading the view.}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end
```

\
Now, when we Run the project, our project look like this: at the bottom of the app we can toggle between the two tabs and both have different views:

![iOS : Creating Sample on Tab Bar controller](https://www.mindstick.com/mindstickarticle/046e20bf-f5d7-434f-b6e3-3770096e82a2/images/794c35e6-3b62-43b5-90af-be243f6248d9.png)\

---

Original Source: https://www.mindstick.com/articles/1841/ios-creating-sample-on-tab-bar-controller

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
