SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!

Overview

SAHistoryNavigationViewController

Platform Language Version License

Support 3D Touch for iOS9!!

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller.

ManiacDev.com referred.
https://maniacdev.com/2015/03/open-source-component-enhancing-the-back-button-with-view-history-navigation

Features

  • iOS task manager like UI
  • Launch Navigation History with Long tap action of Back Bar Button
  • Support Swift2.0
  • Support 3D Touch (If device is not supported 3D Touch, automatically replacing to long tap gesture.)
  • Support Swift2.3
  • Sipport Swift3

Installation

CocoaPods

SAHistoryNavigationViewController is available through CocoaPods. If you have cocoapods 0.38.0 or greater, you can install it, simply add the following line to your Podfile:

pod "SAHistoryNavigationViewController"

Manually

Add the SAHistoryNavigationViewController directory to your project.

Usage

If you install from cocoapods, You have to write import SAHistoryNavigationViewController.

Storyboard or Xib

Set custom class of UINavigationController to SAHistoryNavigationViewController. In addition, set module to SAHistoryNavigationViewController.

Code

You can use SAHistoryNavigationViewController as self.sah.navigationController in any ViewController, bacause implemented extension SAHistoryExtension as below codes.

public protocol SAHistoryCompatible {
    associatedtype CompatibleType
    var sah: CompatibleType { get }
}

public extension SAHistoryCompatible {
    public var sah: SAHistoryExtension<Self> {
        return SAHistoryExtension(self)
    }
}

public final class SAHistoryExtension<Base> {
    public let base: Base
    public init(_ base: Base) {
        self.base = base
    }
}

extension UIViewController: SAHistoryCompatible {}

extension SAHistoryExtension where Base: UIViewController {
    public var navigationController: SAHistoryNavigationViewController? {
        return base.navigationController as? SAHistoryNavigationViewController
    }
}

And you have to initialize like this.

let ViewController = UIViewController()
let navigationController = SAHistoryNavigationViewController()
navigationController.setViewControllers([ViewController], animated: true)
presentViewController(navigationController, animated: true, completion: nil)

If you want to launch Navigation History without long tap action, use this code.

//In any UIViewController
self.sah.navigationController?.showHistory()

Customize

If you want to customize background of Navigation History, you can use those methods.

//In any UIViewController
self.sah.navigationController?.contentView
self.sah.navigationController?.historyBackgroundColor

This is delegate methods.

@objc public protocol SAHistoryNavigationViewControllerDelegate: NSObjectProtocol {
    optional func historyControllerDidShowHistory(controller: SAHistoryNavigationViewController, viewController: UIViewController)
}

Requirements

Author

Taiki Suzuki, [email protected]

License

SAHistoryNavigationViewController is available under the MIT license. See the LICENSE file for more info.

Comments
  • Crash when inheriting SAHistoryNavigationViewController

    Crash when inheriting SAHistoryNavigationViewController

    I gave this lib a try but discovered a nasty crash when using it on iOS 9.2 Here's the end of the stack trace.

    * thread #1: tid = 0x9b91cc, 0x0000000103fd1dbb libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
        frame #0: 0x0000000103fd1dbb libobjc.A.dylib`objc_exception_throw
        frame #1: 0x000000010304ad9d CoreFoundation`+[NSException raise:format:] + 205
        frame #2: 0x0000000101466f0a UIKit`-[UINavigationBar setDelegate:] + 81
      * frame #3: 0x00000001012c228a SAHistoryNavigationViewController`SAHistoryNavigationViewController.SAHistoryNavigationViewController.viewDidLoad (self=<unavailable>)() -> () + 1418 at SAHistoryNavigationViewController.swift:101
        frame #4: 0x0000000100337059 CaptainJet`CaptainJet.CaptainJetNavigationController.viewDidLoad (self=0x00007fc03304e200)() -> () + 41 at CaptainJetNavigationController.swift:16
        frame #5: 0x0000000100337932 CaptainJet`@objc CaptainJet.CaptainJetNavigationController.viewDidLoad (CaptainJet.CaptainJetNavigationController)() -> () + 34 at CaptainJetNavigationController.swift:0
        frame #6: 0x0000000101508f98 UIKit`-[UIViewController loadViewIfRequired] + 1198
        frame #7: 0x00000001015092e7 UIKit`-[UIViewController view] + 27
        frame #8: 0x000000010155184b UIKit`-[UINavigationController pushViewController:transition:forceImmediate:] + 663
        frame #9: 0x0000000101551299 UIKit`-[UINavigationController pushViewController:animated:] + 848
        frame #10: 0x00000001012c28d8 
    

    The debugger gives this output: Cannot manually set the delegate on a UINavigationBar managed by a controller.

    Looking at the documentation you can see that:

    If the navigation bar was created by a navigation controller and is being managed by that object, you must not change the value of this property. Navigation controllers act as the delegate for any navigation bars they create.

    This is what is happening here. The controller automatically becomes the navigationBar delegate. I think this line should be removed. Let me know if you need a PR I would happily do so.

    opened by apouche 5
  • Some desired changes

    Some desired changes

    The code here:

    1. Solves the bug where the SAHistoryNavigationViewController extends behind status bar if a modal UIViewController is presented.
    2. Removes any custom animation and works purely by following the delegate methods. (IMHO, the animation should be a different pod altogether)
    3. Uses some functional constructs where it makes understanding code easier.
    4. Extends Sample to present a UIViewController modally.

    Some of these changes might be in conflict with what you had planned for this pod. In that case, I would like to create a different pod from this. Also, if you have any suggestions for the code which could make this merge, would love to know them. :innocent:

    opened by ayushgoel 5
  • Crash when navigation between screens is half complete and reverted

    Crash when navigation between screens is half complete and reverted

    Hi, First off, great control utility for ios, thanks a bunch, I came across this peculiar bug, i've uploaded the procedure here, and its reproducible. Please have a look. I'm trying to fix this up myself, i'll submit a pull request if i'm successful :) https://www.youtube.com/watch?v=unzY6lAhSeo&feature=youtu.be

    opened by giridharvc7 5
  • Warning when going back and a tabbar controller has been pushed

    Warning when going back and a tabbar controller has been pushed

    The warning is: Unbalanced calls to begin/end appearance transitions for UITabBarController: 0x7fb91bd2a850.

    Consider the following scenario in storyboards:

    • Have a navigation controller as the initial view controller wit a UIViewController
    • Add a button to the UIViewController that leads to a UITabbarController

    Tap on the button to see the tabbar controller, then long press the back button to see the error above.

    I can provide you a zip file if you want with this test case, no code involved, just storyboards.

    opened by pepejeria 4
  • Added support for landscape orientation

    Added support for landscape orientation

    Added support for mixing landscape and portrait orientations when navigating through a UINaivigationController. This feature is especially useful for tablets, where supporting just one orientation is not practical.

    In regards to supporting both portrait and landscape, there is one aspect worth discussing: when restoring a landscape screenshot into a portrait screen or viceversa, how should the animation look? Stretching the photo to fill the new size did not look right to me, so I left the old behavior, which zooms the image until it hits one of the screen's edges, then, it is replaced by destination VC with the proper bounds.

    opened by ratzinho87 1
  • Cannot set if historyContentView.backgroundColor

    Cannot set if historyContentView.backgroundColor

    Hi! First of all, I would like to say that this is one of the greatest new functionality I have seen in a long time, It perfectly fits in my app!

    There is just one little tiny detail on iOS 9.2 setting up background color gets overriten in SAHistoryNavigationViewController.swift on line 49. I haven't tested this on any other version of iOS, but I am pretty sure that it won't work also.

    So I have made a really tiny change, basically just check if backgroundColor is already set, if so It won't get ser on grayColor.

    Tested and It works now.

    opened by syky27 1
  • Very simple fix for animation flickering issue when returning to selected view controller from history.

    Very simple fix for animation flickering issue when returning to selected view controller from history.

    Before when selecting a view controller from the history, the navigation bar would be animating in at the same time, doing it without animation solves this problem and the transition is much nicer looking.

    Cheers! This is a great idea!

    opened by jakemarsh 1
  • [#38] fixed crash when changing navbar delegate

    [#38] fixed crash when changing navbar delegate

    According to Apple documentation:

    If the navigation bar was created by a navigation controller and is being managed by that object, you must not change the value of this property. Navigation controllers act as the delegate for any navigation bars they create.

    Since this is exactly what's happening here, the OS triggers a trap and any controller subclassing SAHistoryNavigationViewController will crash as well.

    Simply removing the delegate assignment solves this issue.

    opened by apouche 0
Releases(3.0.0)
Owner
Taiki Suzuki
AbemaTV / University of Aizu 18th
Taiki Suzuki
Lightweight touch visualization library in Swift. A single line of code and visualize your touches!

TouchVisualizer is a lightweight pure Swift implementation for visualising touches on the screen. Features Works with just a single line of code! Supp

Morita Naoki 851 Dec 17, 2022
🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction ?? Awesome search view, written in Swift 5.0, appears search view like Pinteres

Kyle Yi 1.2k Dec 17, 2022
List tree data souce to display hierachical data structures in lists-like way. It's UI agnostic, just like view-model and doesn't depend on UI framework

SwiftListTreeDataSource List tree data souce to display hierachical data structures in lists-like way. It's UI agnostic, just like view-model, so can

Dzmitry Antonenka 26 Nov 26, 2022
A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

Putra Z. 43 Feb 4, 2022
MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.

MZFormSheetPresentationController MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding sup

Michał Zaborowski 979 Nov 17, 2022
SheetPresentation for SwiftUI. Multiple devices support: iOS, watchOS, tvOS, macOS, macCatalyst.

SheetPresentation for SwiftUI. Multiple devices support: iOS, watchOS, tvOS, macOS, macCatalyst.

Aben 13 Nov 17, 2021
An UITextView in Swift. Support auto growing, placeholder and length limit.

GrowingTextView Requirements iOS 8.0 or above Installation CocoaPods GrowingTextView is available through CocoaPods. To install it, simply add the fol

Kenneth Tsang 941 Jan 5, 2023
A UINavigationController subclass that support pop interactive UINavigationbar with hidden or show.

KDInteractiveNavigationController Features ✨ UINavigationController interactive with UINavigationBar hidden or show Hide all UINavigationController ba

Kingiol 154 Dec 3, 2022
A UITextView subclass that adds support for multiline placeholder written in Swift.

KMPlaceholderTextView A UITextView subclass that adds support for multiline placeholder written in Swift. Usage You can set the value of the placehold

Zhouqi Mo 794 Jan 7, 2023
Powerful and easy-to-use vector graphics Swift library with SVG support

Macaw Powerful and easy-to-use vector graphics Swift library with SVG support We are a development agency building phenomenal apps. What is Macaw? Mac

Exyte 5.9k Jan 1, 2023
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022
Pull up controller with multiple sticky points like in iOS Maps

PullUpController Create your own pull up controller with multiple sticky points like in iOS Maps Features Multiple sticky points Landscape support Scr

Mario Iannotta 1.2k Dec 22, 2022
A fancy hexagonal layout for displaying data like your Apple Watch

Hexacon is a new way to display content in your app like the Apple Watch SpringBoard Highly inspired by the work of lmmenge. Special thanks to zenly f

Gautier Gédoux 340 Dec 4, 2022
A horizontal scroll dial like Instagram.

HorizontalDial Preview Requirements iOS 8.0+ Swift 5 Storyboard support Installation CocoaPods use_frameworks! pod "HorizontalDial" Manually To instal

Lee Sun-Hyoup 210 Nov 22, 2022
You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.

PullToDismiss PullToDismiss provides dismiss modal viewcontroller function like Facebook Messenger by pulling scrollview or navigationbar with smooth

Suguru Kishimoto 479 Dec 5, 2022
RangeSeedSlider provides a customizable range slider like a UISlider.

RangeSeekSlider Overview RangeSeekSlider provides a customizable range slider like a UISlider. This library is based on TomThorpe/TTRangeSlider (Objec

WorldDownTown 644 Dec 12, 2022
🍞 Toast for Swift - Toaster Android-like toast with very simple interface

Toaster Android-like toast with very simple interface. (formerly JLToast) Screenshots Features Queueing: Centralized toast center manages the toast qu

Suyeol Jeon 1.6k Jan 3, 2023
A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize.

SwiftUI Drawer A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize. Contents Add the Package Basic Usage Examples Credits

Michael Verges 695 Jan 3, 2023