indievox-inc / TabBarSplitViewController

Adaptive UISplitViewController with UITabBarController as primary view controller.
MIT License
18 stars 3 forks source link

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/indievox-inc/TabBarSplitViewController'
use_frameworks!

Run pod update.

Carthage

Cartfile

github "indievox-inc/TabBarSplitViewController"

Follow instructions on Carthage.

Git Submodule

Add as submodule and clone:

git submodule add https://github.com/indievox-inc/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.

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).

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 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:

Licenses

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