Skip to content

Adaptive UISplitViewController with UITabBarController as primary view controller.

License

Notifications You must be signed in to change notification settings

denkeni/TabBarSplitViewController

 
 

Repository files navigation

TabBarSplitViewController

Build Status Carthage compatible GitHub license

Adaptive UISplitViewController that works with UITabBarController as primary view controller.

TabBarSplitViewController Example screenshot in iPad TabBarSplitViewController Example screenshot in iPhone 6 Plus simulator

(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)!

Introduction

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)

Requirements

iOS 8 or later

Add to Your Project

Cocoapods

Podfile

In light of this discussion, we encourage this form:

pod 'TabBarSplitViewController', :git => 'https://github.com/denkeni/TabBarSplitViewController'
use_frameworks!

Run pod update.

Carthage

Cartfile

github "denkeni/TabBarSplitViewController"

Follow instructions on Carthage.

Git Submodule

Add as submodule and clone:

git submodule add https://github.com/denkeni/TabBarSplitViewController

Then manually add to your project, as follows:

Manually

Dependency Project

  1. Drag TabBarSplitViewController.xcodeproj into your project.
  2. Project settings - Targets - General - Embedded Binaries: add TabBarSplitViewController.frameworkiOS

Source Code

Or just drag TabBarSplitViewController.swift into your project.

How to Use

Import TabBarSplitViewController Framework

For Swift projects, import TabBarSplitViewController before using it. See Example.

Init TabBarSplitViewController

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.

Test Your Navigation Flow

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.

Afterword

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.

Licenses

All source code is licensed under the MIT License. See LICENSE.

About

Adaptive UISplitViewController with UITabBarController as primary view controller.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 95.0%
  • Ruby 2.7%
  • Objective-C 2.3%