Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)

Overview

Swift 4.2 Platforms iOS CocoaPods Carthage Swift Package Manager License MIT

AEAccordion

UITableViewController with accordion effect (expand / collapse cells)

Simple and lightweight solution for making accordion effect in table view controller. Show detailed content on demand.

AEAccordion

Index

Features

  • Create accordion effect in table view controller with less effort
  • Animate expansion / collapsing of cells as you want (optional)
  • Automatic scroll on cell expansion to make entire cell visible (optional)

Usage

  • Subclass AccordionTableViewCell and override setExpanded:animated:.
import AEAccordion

final class ReadmeTableViewCell: AccordionTableViewCell {

    static let reuseIdentifier = "ReadmeTableViewCell"
    
    @IBOutlet weak var headerView: HeaderView!
    @IBOutlet weak var detailView: DetailView!
    
    // MARK: Override
    
    override func setExpanded(_ expanded: Bool, animated: Bool) {
        super.setExpanded(expanded, animated: animated)
        
        if animated {
            UIView.transition(with: detailView, duration: 0.3, animations: {
                self.detailView.isHidden = !expanded
            }, completion: nil)
        } else {
            detailView.isHidden = !expanded
        }
    }
    
}
  • Subclass AccordionTableViewController and configure cell height based on expandedIndexPaths.
import AEAccordion

final class ReadmeTableViewController: AccordionTableViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        expandFirstCell()
    }
    
    func expandFirstCell() {
        let firstCellIndexPath = IndexPath(row: 0, section: 0)
        expandedIndexPaths.append(firstCellIndexPath)
    }
    
    // MARK: UITableViewDelegate
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return expandedIndexPaths.contains(indexPath) ? 200.0 : 50.0
    }
    
}

For more details check out Sources and Example.

Installation

License

This code is released under the MIT license. See LICENSE for details.

Comments
  • How to using didselectrow to get the string name

    How to using didselectrow to get the string name

    Hello, i'm trying to get the header name of the selected row. But when i use didSelectRowAt indexPath what i get is empty string. How can i implement didSelectRowAt in this accordion?

    opened by renzrz 3
  • Collapse only when tap on HeaderView

    Collapse only when tap on HeaderView

    Hi, I have used this awesome AEAccordion, But running into an issue, we have an business requirement to collapse tableview cell only when tap on HeaderView. At present when we tap any where on expanded cell it collapse.

    Can you please help me to solve this issue ?

    opened by SenthilKaliathan 1
  • Unable to install using cocoapods

    Unable to install using cocoapods

    Adding

        pod 'AEXibceptionView', '~> 1.0.3'
        pod 'AEAccordion', '~> 1.0.3'
    

    to the pod file and doing a pod install results in the following message:

    [!] Unable to satisfy the following requirements:
    
    - `AEAccordion (~> 1.0.3)` required by `Podfile`
    

    Other pods seem to be working, so I was wondering if you have an issue in the podspec?

    opened by mdrewitt 0
  • setExpand() function is not working

    setExpand() function is not working

    The setExpanded function is not working in my case.

    override func setExpanded(_ expanded: Bool, animated: Bool)

    I recently used it if I set the first cell to expand, it gets proper given width and height. All the others cells did not get the given height and width and the expand collapse is not working.

    opened by Taimoor20 0
  • If # of cells is large, collapsing last cell will scroll up too far

    If # of cells is large, collapsing last cell will scroll up too far

    Normally, collapsing a cell will allow the cell to still be visible within the viewing window.

    However, if the # of cells is large, and the last cell is opened and then collapsed, the tableview will scroll up far enough to make the last cell not visible (causing the user have to scroll all the way back down to make the cell visible again).

    Any suggestions on fixing this? It only applies to the last cell or two in a large table.

    bug help wanted 
    opened by st34m3dr1c3 0
Owner
Marko Tadić
keep it simple
Marko Tadić
Collapse and expand UICollectionView sections with one method call.

This library provides a custom UICollectionView that allows to expand and collapse sections. Provides a simple API to manage collection view appearanc

Touchlane 172 Dec 26, 2022
`SimpleExpandableView` is a SwiftUI view which can collapse and expand the content

SimpleExpandableView 中文说明 ExpandableView structure Example ExpandableView( headerSize: CGSize(width: 250.0, height: 50.0), cardSize: CGSize(wi

Tomortec 5 Oct 6, 2022
INTUZ is presenting an interesting a Multilevel Expand/Collapse UITableView App Control to integrate inside your native iOS-based application

INTUZ is presenting an interesting a Multilevel Expand/Collapse UITableView App Control to integrate inside your native iOS-based application. MultilevelTableView is a simple component, which lets you use the tableview with multilevel tree view in your project.

INTUZ 3 Oct 3, 2022
Dynamically hide / show cells of static UITableViewController

Dynamically hide / show cells of static UITableViewController, Swift Port of StaticDataTableViewController. Installation CocoaPods pod 'StaticTableVie

muyexi 26 Sep 16, 2022
GenericTableViewController - An example to use of generics with UITableViewController

GenericTableView An example to use of generics with UITableViewController. With

Gagan Vishal Mishra 1 Mar 21, 2022
Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController.

Todo Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController

Jake Lin 273 Dec 29, 2022
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎡 written in Swift

CenteredCollectionView CenteredCollectionView is a lightweight drop in place UICollectionViewFlowLayout that pages and keeps its cells centered, resul

Ben Emdon 1.2k Jan 6, 2023
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎡 written in Swift

CenteredCollectionView CenteredCollectionView is a lightweight drop in place UICollectionViewFlowLayout that pages and keeps its cells centered, resul

Ben Emdon 1.2k Dec 6, 2022
Thomas Grapperon 32 Dec 12, 2022
Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

appssemble 544 Dec 28, 2022
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
ExpandableText 😎 (SwiftUI) Expand the text with the "more" button

ExpandableText ?? (SwiftUI) Expand the text with the "more" button Get Started import SwiftUI import ExpandableText struct ExpandableText_Test: View

null 35 Dec 26, 2022
Multiliner - An Xcode source extension to expand lengthy lines

Multiliner An Xcode source extension to expand lengthy lines. Super lightweight, 1 file. It expands long lines. That's it! Works with: Initializers Fu

Andrew Zheng 629 Jan 4, 2023
A cells of UITableView can be rearranged by drag and drop.

TableViewDragger This is a demo that uses a TableViewDragger. Appetize's Demo Requirements Swift 4.2 iOS 8.0 or later How to Install TableViewDragger

Kyohei Ito 515 Dec 28, 2022
BouncyLayout is a collection view layout that makes your cells bounce.

BouncyLayout is a collection view layout that makes your cells bounce. Features Pure Swift 5. Works with every UICollectionView. Horizontal and vertic

Robert-Hein Hooijmans 4.2k Jan 5, 2023
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022
Some cells to Form a Pod

CellsGao Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation CellsGao

null 0 Nov 2, 2021
A Swift library for swipeable table cells

BWSwipeRevealCell Using the library **Note: Use version 1.0.1 for Swift 2.3 support and version 2.0.0 or higher for Swift 3 support ** There are two m

Kyle Newsome 67 May 11, 2022
UICollectionView layout for presenting of the overlapping cells.

StickyCollectionView UICollectionView layout for presenting of the overlapping cells. Objective-C version here Checkout demo Overview Installation Man

Bogdan Matveev 325 Oct 11, 2022
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022