Adaptive UISplitViewController
that works with UITabBarController
as primary view controller.
(Not what you're looking for? You may be looking for another UI structure: daveanderson/TabsAndSplits)
If you're using UITabBarController
/ UINavigationController
as rootViewController to build an iPhone-only app, there's NO REASON NOT TO BE AN UNIVERSAL APP ANYMORE!
Fully compatible with iOS 9 iPad multitasking (Slide Over/Split View)!
UISplitViewController
(master-detail interface) becomes universal for both iPad and iPhone, with introduction of size classes in iOS 8. However, UISplitViewController
default behavior (without implementing UISplitViewControllerDelegate
) is limited:
TabBarSplitViewController | UISplitViewController | |
---|---|---|
Primary use UITabBarController |
YES (optional) | No (UINavigationController suggested) |
Secondary use UINavigationController |
YES (optional) | No |
Secondary empty state | YES (Customizable) | No (should start with nil) |
iOS 8 or later
In light of this discussion, we encourage this form:
pod 'TabBarSplitViewController', :git => 'https://github.com/indievox-inc/TabBarSplitViewController'
use_frameworks!
Run pod update
.
github "indievox-inc/TabBarSplitViewController"
Follow instructions on Carthage.
Add as submodule and clone:
git submodule add https://github.com/indievox-inc/TabBarSplitViewController
Then manually add to your project, as follows:
TabBarSplitViewController.xcodeproj
into your project.TabBarSplitViewController.frameworkiOS
Or just drag TabBarSplitViewController.swift
into your project.
For Swift projects, import TabBarSplitViewController
before using it. See Example.
For Objective-C projects, #import "TabBarSplitViewController/TabBarSplitViewController-Swift.h"
before using it, and change project settings - Targets - Build Settings - Embedded Content Contains Swift Code
to YES
. See Example-ObjC (carthage update
before running it).
Set it as windows's rootViewController.
All view controllers of the tabBarViewController should be UINavigationController
, with respective view controller of each tab as its rootViewController.
Always simplify or design your navigation flow logic with caution!
In primary view controller, showViewController
(push to primary) / showDetailViewController
(push to secondary) are preferred rather than the old pushViewController
.
Further reading: WWDC 2014 Session 216: Building Adaptive Apps with UIKit for knowledge of implementation details.
This project powered LiVE EVIL app of iNDIEVOX Inc., and is planned to be maintained with the latest Swift and Xcode version. is written in Swift 2.2, and will not be maintained in this repository anymore. Please check other forked repositories.
If you prefer Objective-C to avoid dependency hell of fast-moving Swift version (See: Is It Time for Swift?), or if you're using customized view for tab bar, port the source code and build your own should be easy now, by referencing the original implementation.
There are one UI logic flaw in this UI structure, though not a big concern:
showDetailViewController
of view controller inside tab #1 in regular size class, tap tab #2, and then changed to compact size class will collapse the secondary and push the view controller of tab #1 onto tab #2.All source code is licensed under the MIT License. See LICENSE.