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/denkeni/TabBarSplitViewController'
use_frameworks!
Run pod update
.
github "denkeni/TabBarSplitViewController"
Follow instructions on Carthage.
Add as submodule and clone:
git submodule add https://github.com/denkeni/TabBarSplitViewController
Then manually add to your project, as follows:
- Drag
TabBarSplitViewController.xcodeproj
into your project. - Project settings - Targets - General - Embedded Binaries: add
TabBarSplitViewController.frameworkiOS
Or just drag TabBarSplitViewController.swift
into your project.
For Swift projects, import TabBarSplitViewController
before using it. See Example.
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 powers my app Playlist Note, was initiated from my previous project LiVE EVIL app of iNDIEVOX Inc., and is expected to be maintained with the latest Swift and Xcode version.
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.