How to add a tab bar controller to your app
A tab bar controller gives an iPhone app several primary sections without stacking every destination onto one navigation hierarchy. UIKit’s UITabBarController manages the bar along the bottom and swaps the visible root view controller when the user selects a tab. It suits apps that move between browsing, activity, saved items and account tools.
The useful part is not just the bar itself; it is the behaviour behind each selection. A tab should own its navigation history, reopen on the expected screen and remain comfortable to use one-handed. This guide builds a UIKit implementation in Xcode, then explains presentation choices, state handling and the checks that prevent a familiar navigation mistake.
Plan the tab structure before coding
Design around destinations, not screens. A user should be able to name each area of the app in one word, such as Discover, Trips, Saved and Account. If two labels describe the same place, merge them. If an action appears only once or twice, put it inside the relevant section instead of giving it a permanent tab.
Keep the bar to three or four tabs where possible. More choices reduce label space, particularly on smaller iPhones and for users with larger text. The bar is for switching between peer sections, not a shortcut shelf for every button. A transport app might expose Plan, Live updates, Favourites and Account instead of separate tickets, timetables and settings buttons.
Australian context can guide those labels and priorities. Sydney commuters and Melbourne tram passengers often check live journey information while travelling, so a transport product can make that area prominent. Use Australian English such as “organisation” and “favourites” consistently, while localisation may also need to support the multilingual communities in major Australian cities.
Paid navigation features deserve a local market check too: Australian App Store purchases are displayed in Australian dollars (AUD), which affects pricing copy and upgrade prompts. Also remember that an iPad may present the same tab controller differently from an iPhone. Test every layout, and never rely on colour alone to show the selected tab.
Create the tab bar controller at launch
In UIKit, UITabBarController is usually the window’s root view controller, with one root screen for each tab. A navigation controller can sit inside it, but the tab controller must remain the outer container so UIKit can swap sections when the user taps the bar.
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let windowScene = scene as? UIWindowScene else { return }
let window = UIWindow(windowScene: windowScene)
window.rootViewController = AppTabBarController()
self.window = window
window.makeKeyAndVisible()
}
}
With a storyboard, add a tab bar controller to Main.storyboard, give it a custom class if needed, and make it the initial view controller. The scenes for each tab remain ordinary view controllers. Programmatic setup can be easier to review in a small Xcode project because the full hierarchy is visible in one file.
Do not create the controller repeatedly inside view-loading methods. A new instance replaces the tab state, loses the active selection and can interrupt work in progress. Create it when the scene connects, keep a stable reference through the window, and configure its children once.
For another UIKit-focused perspective from a developer in Kazakhstan, the iOS development notes provide useful examples of building native Apple-platform apps.
Compare the main implementation paths
The main implementation paths differ in where the container is declared and how Xcode represents its children:
| Approach | How the root is created | Best fit | Main limitation |
|---|---|---|---|
| Programmatic UIKit | Instantiate it in SceneDelegate and assign viewControllers in code |
Full control and straightforward review | Relationships must be written and maintained in Swift |
| Storyboard | Add UITabBarController and relationship segues in Interface Builder |
Visual setup for designers | Connections can become difficult to inspect in large projects |
SwiftUI TabView |
Declare tabs as SwiftUI values | A SwiftUI interface | Uses a different navigation model and is not a UIKit tab bar controller |
Programmatic UIKit is the clearest choice for the example here because the ownership of each tab is explicit. It also makes it harder to accidentally add a screen to the wrong navigation stack. If an existing project already relies on storyboards, a storyboard tab controller remains supported; the concepts of root screens and independent stacks still apply.
Mixed projects need extra care. A SwiftUI view can be hosted inside UIKit with UIHostingController, and that hosted controller can become a tab just like a UIKit screen. The surrounding application is still a UITabBarController, so use whichever framework fits each feature rather than forcing old screens into a new architecture.
Choose based on the app you have, not the approach that sounds newest. A small UIKit sample can stay entirely programmatic, while a designer-led project may benefit from storyboard relationships. The basic rule remains the same: every visible tab needs a clear root and a stable identity.
Give each tab independent navigation
Give each tab its own UINavigationController. This lets a user drill down inside Discover, switch to Trips, then return to Discover and find the same screen still on the navigation stack. A single shared navigation controller cannot preserve that separation because its history belongs to the whole application.
final class AppTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let discover = makeNavigationController(
root: DiscoverViewController(),
title: "Discover",
image: UIImage(systemName: "safari")
)
let trips = makeNavigationController(
root: TripsViewController(),
title: "Trips",
image: UIImage(systemName: "tram.fill")
)
let account = makeNavigationController(
root: AccountViewController(),
title: "Account",
image: UIImage(systemName: "person.crop.circle")
)
viewControllers = [discover, trips, account]
}
private func makeNavigationController(
root: UIViewController,
title: String,
image: UIImage?
) -> UINavigationController {
let controller = UINavigationController(rootViewController: root)
controller.tabBarItem = UITabBarItem(
title: title,
image: image,
selectedImage: nil
)
return controller
}
}
Replace the placeholder controllers with your existing screens. The viewControllers array determines both the order and visibility of the tabs. Keep titles stable because they also appear in VoiceOver and other accessibility contexts.
Use distinct symbols that remain understandable at small sizes, and supply selected and unselected artwork where the design requires it. The system applies the tint and accessibility behaviour, but custom assets still need sufficient contrast. Avoid changing the bar’s height to squeeze in extra controls; shorter labels and clearer information architecture are safer.
Decide how selection is preserved. A common pattern keeps the tab controller alive, retains each navigation stack, and changes only selectedIndex when a notification, search result or deep link requests another section. For deep links, map the incoming URL to a tab first, then push the matching detail screen onto that tab’s navigation controller.
Ship a dependable tab bar experience
Most defects appear when the basic container is sound but the surrounding behaviour is incomplete. Use these checks before testing with other developers or submitting a build:
Build checks
- Confirm every tab has one stable root controller and its own navigation stack.
- Keep titles, symbols and ordering consistent across phone, tablet and accessibility layouts.
- Verify that switching tabs does not discard an in-progress form or an active playback session.
- Check Australian English, localisation and AUD pricing where relevant.
Release checks
- Test the smallest supported iPhone, large Dynamic Type, VoiceOver and both light and dark appearances.
- Exercise background and foreground transitions, state restoration and notifications that open a specific tab.
- Validate deep links after the app has been relaunched, not only while it is already running.
- Review keyboard behaviour so a form inside one tab cannot remain covered in another.
Appearance can be refined with UITabBarAppearance, including background colours, selected-item contrast and compact or inline layouts. On iPad, evaluate every supported tab bar style because the controls may appear at the top or as a sidebar. The code should adapt, while the meaning and order of the sections should remain constant.
State restoration deserves particular attention. If the app stores the selected tab, restore it only after the controller and all child navigators exist. Otherwise, the system can restore stale view controller identifiers. Store lightweight preferences and reconstruct screens from those preferences instead of serialising an entire view hierarchy.
Remember that the controller is only the container. What users remember is whether each section has a clear purpose, whether navigation stays in place after a switch, and whether the interface remains accessible on every supported device. A stable UITabBarController makes those qualities feel effortless.