All Projects → jeantimex → Collapsibletablesectionviewcontroller

jeantimex / Collapsibletablesectionviewcontroller

Licence: mit
🎉 Swift library to support collapsible sections in a table view.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Collapsibletablesectionviewcontroller

Csmodel
CSModel is a concise and efficient model framework for iOS/OSX, and provides nested Model to compare values and copy values.
Stars: ✭ 192 (-36.84%)
Mutual labels:  cocoapod
pikko
Color picker for iOS made with ❤️
Stars: ✭ 34 (-88.82%)
Mutual labels:  cocoapod
Intro
An iOS framework to easily create simple animated walkthrough, written in Swift.
Stars: ✭ 33 (-89.14%)
Mutual labels:  cocoapod
Dtphotoviewercontroller
A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.
Stars: ✭ 212 (-30.26%)
Mutual labels:  cocoapod
trace-cocoa-sdk
Catch bugs before they reach production — get detailed crash reports and monitor how your app is performing across the entire install base.
Stars: ✭ 15 (-95.07%)
Mutual labels:  cocoapod
DSFFloatLabelledTextControl
A macOS Cocoa single-line NSTextField/NSSecureTextField that implements the Float Label Pattern.
Stars: ✭ 21 (-93.09%)
Mutual labels:  cocoapod
Ghosttypewriter
👻 A UILabel subclass that adds a typewriting animation effect
Stars: ✭ 159 (-47.7%)
Mutual labels:  cocoapod
CollectionAndTableViewCompatible
A set of Swift protocols and Xcode snippets that will make it easy to do clean UITableView code
Stars: ✭ 34 (-88.82%)
Mutual labels:  cocoapod
kmp-fatframework-cocoa
A Gradle plugin to generate and publish an iOs FatFramework or XCFramework on Kotlin Multiplatform projects.
Stars: ✭ 26 (-91.45%)
Mutual labels:  cocoapod
QuizKit
⁉️ A framework for developing local or remote quiz apps for iOS or tvOS
Stars: ✭ 28 (-90.79%)
Mutual labels:  cocoapod
Fusuma
Instagram-like photo browser and a camera feature with a few line of code in Swift.
Stars: ✭ 2,434 (+700.66%)
Mutual labels:  cocoapod
salsa
A tool for exporting iOS components into Sketch 📱💎
Stars: ✭ 62 (-79.61%)
Mutual labels:  cocoapod
ParseCareKit
Securely synchronize any CareKit 2.1+ based app to a Parse Server Cloud. Compatible with parse-hipaa.
Stars: ✭ 28 (-90.79%)
Mutual labels:  cocoapod
Swiftycomments
UITableView based component designed to display a hierarchy of expandable/foldable comments.
Stars: ✭ 200 (-34.21%)
Mutual labels:  cocoapod
Snackbar-iOS
Simple snackbar for ios from android platform
Stars: ✭ 17 (-94.41%)
Mutual labels:  cocoapod
Persistentstorageserializable
Swift library that makes easier to serialize the user's preferences (app's settings) with system User Defaults or Property List file on disk.
Stars: ✭ 162 (-46.71%)
Mutual labels:  cocoapod
authorize-me
Authorization with social networks
Stars: ✭ 44 (-85.53%)
Mutual labels:  cocoapod
Xestimonitors
An extensible monitoring framework written in Swift
Stars: ✭ 269 (-11.51%)
Mutual labels:  cocoapod
SSCustomSideMenu
Side Menu Custom Control for iOS apps
Stars: ✭ 50 (-83.55%)
Mutual labels:  cocoapod
GravityTagCloudView
A tag cloud view with gravity.
Stars: ✭ 22 (-92.76%)
Mutual labels:  cocoapod

CollapsibleTableSectionViewController

Platform Swift 4.2 CocoaPods Carthage compatible Build codecov.io License Donate

A Swift library that helps you collapse table view sections.

cover

Features

  • Support collapsible sections in a table view
  • Collapse all the sections by default (configurable)
  • Keep only one section expanded (configurable)
  • Auto resize table view cell
  • Easy-to-use protocols for configuration

Requirements

  • iOS 9.0+
  • Xcode 10.0+
  • Swift 4.2

Installation

Manual

Just clone and add the following Swift files to your project:

  • CollapsibleTableSectionViewController.swfit
  • CollapsibleTableViewHeader.swift

Cocoapods

  • Make sure that you use latest stable Cocoapods version: pod --version
  • If not, update it: sudo gem install cocoapods
  • pod init in you project root dir
  • nano Podfile, add:
use_frameworks! 
pod 'CollapsibleTableSectionViewController', '~> 2.0.1'
  • Save it: ctrl-x, y, enter
  • pod update
  • Open generated .xcworkspace
  • Don't forget to import CollapsibleTableSectionViewController: import CollapsibleTableSectionViewController!

Carthage

  • nano Cartfile
  • put github "jeantimex/CollapsibleTableSectionViewController" ~> 2.0.1 into Cartfile
  • Save it: ctrl-x, y, enter
  • Run carthage update
  • Copy CollapsibleTableSectionViewController.framework from Carthage/Build/iOS to your project
  • Make sure that CollapsibleTableSectionViewController is added in Embedded Binaries section of your target (or else you will get dyld library not loaded referenced from ... reason image not found error)
  • Add import CollapsibleTableSectionViewController on top of your view controller's code

Usage

Step 1. Subclass CollapsibleTableSectionViewController

import CollapsibleTableSectionViewController

class ViewController: CollapsibleTableSectionViewController { ... }

Step 2. Conforms to the CollapsibleTableSectionDelegate protocol

extension ViewController: CollapsibleTableSectionDelegate { ... }

CollapsibleTableSectionDelegate Protocol

Most of the protocol methods are optional and they are very similar to UITableViewDataSource and UITableViewDelegate, here is a list of the available protocol methods:

1. optional func numberOfSections(_ tableView: UITableView) -> Int

Asks the data source to return the number of sections in the table view. Default is 1.

extension ViewController: CollapsibleTableSectionDelegate {
  func numberOfSections(_ tableView: UITableView) -> Int {
    return 10
  }
}

2. optional func collapsibleTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

Returns the number of rows (table cells) in a specified section. Default is 0.

extension ViewController: CollapsibleTableSectionDelegate {
  func collapsibleTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 5
  }
}

3. optional func collapsibleTableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

Returns the table cell at the specified index path. You can also use your custom cells, see our example projects for more details.

extension ViewController: CollapsibleTableSectionDelegate {
  func collapsibleTableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as UITableViewCell? ?? UITableViewCell(style: .default, reuseIdentifier: "Cell")
    cell.textLabel?.text = "Cell Text"
    return cell
  }
}

4. optional func shouldCollapseByDefault(_ tableView: UITableView) -> Bool

Return true if you would like collapse all the sections when the table is loaded. Default is false.

5. optional func shouldCollapseOthers(_ tableView: UITableView) -> Bool

Return true if you would like to keep only one extended section (like accordion style). Default is false.

6. optional func collapsibleTableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?

The title for each section. Default is nil.

7. optional func collapsibleTableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

Tells the delegate that the specified row is now selected.

Examples

Run the Examples project in this repo and you will find the following demos that help you get up and running:

  1. Basic: The minimal working example
  2. Custom Cell: Implement a custom cell programmatically
  3. Collapse By Default: All sections are collapsed by default
  4. Collapse Others: Accordion-style table view that only keeps one section expanded at a time

For more details of how to implement collapsible table sections using Swift, please checkout this repo for more information: https://github.com/jeantimex/ios-swift-collapsible-table-section.

Contribution

Anyone who would like to contribute to the project is more than welcome.

  • Fork this repo
  • Make your changes
  • Submit pull request

License

MIT License

Copyright (c) 2017 Yong Su @jeantimex

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].