✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 4

Overview

USE ExpandableCell. New version of this library.

YNExpandableCell

Awesome Version Carthage Compatible CocoaPods License: MIT Build Status Platform Swift 4.2

Updates

See CHANGELOG for details

Intoduction

Easiest usage of expandable & collapsible cell for iOS, written in Swift 4.2 You can customize expandable UITableViewCell whatever you like. YNExpandableCell is made because insertRows and deleteRows is hard to use. You can just inheirt YNTableViewDelegate and add one more method func tableView(_ tableView: YNTableView, expandCellAt indexPath) -> UITableViewCell?

demo

Requirements

YNExpandableCell written in Swift 3. Compatible with iOS 8.0+

Installation

Cocoapods

YNExpandableCell is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'YNExpandableCell'

Carthage

github "younatics/YNExpandableCell"

Usage

import YNExpandableCell

Make YNTableView in Storyboard or in code

@IBOutlet var ynTableView: YNTableView!

Inherit YNTableViewDelegate

class ViewController: UIViewController, YNTableViewDelegate 

Set delegate and register cells

self.ynTableView.ynDelegate = self

let cells = ["YNExpandableCellEx","YNSliderCell","YNSegmentCell"]
self.ynTableView.registerCellsWith(nibNames: cells, and: cells)
self.ynTableView.registerCellsWith(cells: [UITableViewCell.self as AnyClass], and: ["YNNonExpandableCell"])

Use one of required method

Set expandable cell in YNTableViewDelegate method (Required)

func tableView(_ tableView: YNTableView, expandCellAt indexPath: IndexPath) -> UITableViewCell? {
    let ynSliderCell = tableView.dequeueReusableCell(withIdentifier: YNSliderCell.ID) as! YNSliderCell
    if indexPath.section == 0 && indexPath.row == 1 {
        return ynSliderCell
     }
     return nil
}

Set expandable cell with height in YNTableViewDelegate method using YNTableViewCell object (Required)

func tableView(_ tableView: YNTableView, expandCellWithHeightAt indexPath: IndexPath) -> YNTableViewCell? {
    let ynSliderCell = YNTableViewCell()
    ynSliderCell.cell = tableView.dequeueReusableCell(withIdentifier: YNSliderCell.ID) as! YNSliderCell
    ynSliderCell.height = 142

    if indexPath.section == 0 && indexPath.row == 1 {
        return ynSliderCell
    }
        return nil
}

Get didSelectRowAt in YNTableViewDelegate method (Optional)

func tableView(_ tableView: YNTableView, didSelectRowAt indexPath: IndexPath, isExpandableCell: Bool, isExpandedCell: Bool) {
    print("Selected Section: \(indexPath.section) Row: \(indexPath.row) isExpandableCell: \(isExpandableCell) isExpandedCell: \(isExpandedCell)")
}

Get didDeselectRowAt in YNTableViewDelegate method (Optional)

func tableView(_ tableView: YNTableView, didDeselectRowAt indexPath: IndexPath, isExpandableCell: Bool, isExpandedCell: Bool) {
    print("Deselected Section: \(indexPath.section) Row: \(indexPath.row) isExpandableCell: \(isExpandableCell) isExpandedCell: \(isExpandedCell)")
}

Set basic UITableViewDataSource, UITableViewDelegate and Done!

Customize

Expand & Collapse All if you want

self.ynTableView.expandAll()
self.ynTableView.collapseAll()

Inherit YNExpandableCell if you want awesome '+' '-' custom accessory type

class YNExpandableCellEx: YNExpandableCell

// Change normalCustomAccessoryType, selectedCustomAccessoryType Images

Cutomize UITableViewRowAnimation

self.ynTableView.ynTableViewRowAnimation = UITableViewRowAnimation.top

Make Extensions for more UITableViewDelegate if you need or make pull request for me :)

References

Please tell me or make pull request if you use this library in your application :)

@zigbang

MotionBook

Author

younatics Twitter

License

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

Comments
  • ReloadData() will cause additional expanded view

    ReloadData() will cause additional expanded view

    sorry to give u bad news again.

    If expanded view is open, .reloadData() will cause it to remain and present.

    Tapping on the expandableCell will open another detail page

    screen shot 2017-03-21 at 16 39 37

    bug 
    opened by kohdesmond 15
  • bugs with expandCellWithHeightAt indexPath:

    bugs with expandCellWithHeightAt indexPath:

    I think there's a bug in func tableView(_ tableView: YNTableView, expandCellWithHeightAt indexPath: IndexPath) -> YNTableViewCell?

    if i have only 2 records of cells [0,1], i expand both of them and tried to close cell 0's expanded cell,

    i will get EXC_BAD_INSTRUCTION at line 172, 227 & line 279 in YNTableView.swift

    if internalIndexPath == indexPath {
                    self.didDeselectRowLogicAt(expandedIndexPath: expandedIndexPath, indexPath: indexPath)
                    delegate.tableView(self, didDeselectRowAt: indexPath, isExpandableCell: true, isExpandedCell: false)
                    return
                }
    

    YNTableView.swift is trying to return indexPath.row 2, but my count record only have [0,1].

    i tested with func tableView(_ tableView: YNTableView, expandCellAt indexPath: IndexPath) -> UITableViewCell? and it works fine. Not sure why though @younatics any comments?

    opened by kohdesmond 7
  • Cannot inherit from non-open class 'YNExpandableCell' outside of its defining module

    Cannot inherit from non-open class 'YNExpandableCell' outside of its defining module

    Hi @younatics,

    just a weird thing

    I have to change line 12 of YNTableViewCell.swift from: public class YNExpandableCell: UITableViewCell { into open class YNExpandableCell: UITableViewCell {

    AND

    public override func awakeFromNib() { into open override func awakeFromNib() {

    to eliminate the error.

    not too sure if is an module issues.

    enhancement 
    opened by kohdesmond 4
  • overriding the heightForRowAtIndex doesn't seem to work.

    overriding the heightForRowAtIndex doesn't seem to work.

    In my tableview - my expandable cell needs to be larger than > 44 pixels in height. They are 200 I need to expand to 350.

    perhaps you could provide a method to check cell for initial height....

    screen shot 2017-04-07 at 3 23 37 pm
    // this is obvious fix - but then the expanded cells don't get correct height 
    open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        guard let delegate = self.ynDelegate else {return UITableViewAutomaticDimension}
        guard let heightForRow = delegate.tableView(self, heightForRowAt: indexPath)  else {
                print("height will be 44")
                return UITableViewAutomaticDimension
        }
        return heightForRow
    }
    

    fyi - I'm using it to expand a text section.

    enhancement 
    opened by johndpope 3
  • Add support for multiple cells in expansion

    Add support for multiple cells in expansion

    A really useful addition would be for us to be able to expand multiple cells on tap, which is really useful for screens containing selecting multiple options, checklists, etc. If it's possible, please implement this. Thanks :)

    enhancement 
    opened by dimovskidamjan 3
  • 2 layout bugs discovered

    2 layout bugs discovered

    Hey, first of all thank you for this awesome framework im currently using it in one of my projects.

    i discovered two minor yet annoying bugs in the layout of the cells, the first one is happens when expanding the one before last cell, you can see its content show up in the last cell, here's the GIF link demonstration : whimsicaleachivorybilledwoodpecker-size_restricted

    second bug happens if user multiclick a lot of the cells in a short period of time it basically messes up the layout, here's the GIF link demonstration : glamoroustornibadanmalimbe-size_restricted

    opened by Icy1337 2
  • Using ynTableViewRowAnimation on insert and delete rows

    Using ynTableViewRowAnimation on insert and delete rows

    First thanks for the framework!

    As of now, you are not able to specify the used UITableView UITableViewRowAnimation as the open property ynTableViewRowAnimation is never used - instead .top animation is used. I changed to use ynTableViewRowAnimation.

    opened by cglarsen 2
  • How to define a nonExpandablecell from a nib?

    How to define a nonExpandablecell from a nib?

    Hi YN,

    As above.

    you used an example
    let nonExpandablecell = tableView.dequeueReusableCell(withIdentifier: "YNNonExpandableCell")

    but i want to use a nib file as one of the nonExpandablecell. what should i do?

    Cheers

    Desmond

    opened by kohdesmond 2
  • anyway to open up the animation?

    anyway to open up the animation?

    This is more of a major enhancement. But food for thought.

    i wonder if you can open up the + & - animation for other images and purposes? say expand for more details indicator screen shot 2017-03-21 at 11 12 59

    Once I tap open, it will rotate the arrow pointing up and vice versa

    screen shot 2017-03-21 at 11 16 44

    enhancement 
    opened by kohdesmond 2
  • Getting duplicated overlapping cells

    Getting duplicated overlapping cells

    Hi,

    I've been trying to figure out why I get duplicated cells using your pod.

    screen shot 2017-10-27 at 3 54 05 pm

    Here's the result, but those 2 rows have 2 other rows behind them: screen shot 2017-10-27 at 3 54 29 pm

    As you can see in the image above, my table ends up having 2 copies that are identical, but overlapping. The data is returning 2 rows, but the cellForRowAtIndePath gets called 4 times instead of 2.

    If I take out the code that assigns the ynDelegate to self, i.e.: // self.customTableView.ynDelegate = self, it works fine. But of course I'll lose the functionality that is in this pod.

    I made sure that the UITableView in the storyboard isn't using any delegate/datasource, as these get set when assigning the ynDelegate.

    Please note that I'm not using any expandable cell yet, those cells are just my own custom cells that inherit from UITableViewCell.

    Any help will be greatly appreciated, thanks!

    opened by KBog 1
  • How to check if is a detailed cell for dynamic height.

    How to check if is a detailed cell for dynamic height.

    Hi YN, as title.

    i would like to have a dynamic height for the expanded cell, but i'm not sure how to determine which indexpath should i change the cell height.

    Cheers

    Desmond

    opened by kohdesmond 1
  • The alignment of expandable are not adjust when doing multiple selection.

    The alignment of expandable are not adjust when doing multiple selection.

    When trying to do multiple expandableCell and restoring the any one of previous expandable the other expandable controller crop a bit.

    IMG_4132

    The alignment of expandable are not adjust when doing multiple expandable. Please find attached image for more in details.

    opened by arishanapalli 0
  • Updating values of expandable cells

    Updating values of expandable cells

    Where and how would i update content of expandable cells. e.g values of sliders and segment Control in your case. the delegate method expandCellWithHeight only returns the cells with the set height and doesn't allow me to access the content of the cell. This has been troubling me and i cant find a solution. please update with your response

    opened by usamabinattique 1
  • expandCellWithHeightAt method not calling

    expandCellWithHeightAt method not calling

    While I am setting YNTableViewDelegate then tableview datasource are not getting called and tableview will blank. If I remove your delegate then tableview datasource working.

    `@IBOutlet weak var tableVIewOptions: YNTableView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.tableVIewOptions.ynDelegate = self
        self.tableVIewOptions.dataSource = self
        self.tableVIewOptions.delegate = self
        self.tableVIewOptions.ynTableViewRowAnimation = .top
        
        //hide empty rows
        tableVIewOptions.tableFooterView = UIView()
    }`
    
    opened by sagargondaliya 0
Releases(1.2.1)
Swift library to support collapsible sections in a table view.

CollapsibleTableSectionViewController A Swift library that helps you collapse table view sections. Features Support collapsible sections in a table vi

Su 349 Dec 18, 2022
Make your table view expandable just by implementing one method.

ExpyTableView About ExpyTableView is a re-write based on SLExpandableTableView. Takes some ideas, concepts and codes and regenerates them in Swift. Le

Okhan Okbay 359 Dec 27, 2022
📃 FoldingCell is an expanding content cell with animation made by @Ramotion

FOLDING CELL Expanding content cell with animation inspired by folding paper card material design. We specialize in the designing and coding of custom

Ramotion 10.1k Jan 2, 2023
Three Level Accordian View for IOS

ThreeLevelAccordian ThreeLevelAccordian is a three level accordian for IOS. It owes its base code to SwiftyAccordionCells. Most of the design is custo

Amrata Baghel 44 Sep 23, 2022
Savory is swift accrodion view implementation

Savory Savory is a swift accordion view implementation. Requirements Xcode 8.0 Swift 3.0 iOS 8 Installation Using CocoaPods: pod 'Savory', :git => 'ht

Nandin Borjigin 4 May 30, 2019
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 5

ExpandableCell Intoduction Fully refactored YNExapnadableCell with more concise, bug free. Easiest usage of expandable & collapsible cell for iOS, wri

Kyle Yi 728 Jan 1, 2023
App uses API to display information about City and State user using expandable table cell

Expandable Table Cell iOS App App uses API to display information about City and State user using expandable table cell Implemented Using MVVM with Cl

null 2 Nov 30, 2021
UITableView cell cache that cures scroll-lags on cell instantiating

UITableView + Cache https://github.com/Kilograpp/UITableView-Cache UITableView cell cache that cures scroll-lags on a cell instantiating. Introduction

null 73 Aug 6, 2021
a TableView have thumbnail cell only, and you can use gesture let it expands other expansionView, all diy

ZYThumbnailTableView #####可展开型预览TableView,开放接口,完全自由定制 #####An expandable preview TableView, custom-made all the modules completely with open API you c

null 950 Oct 17, 2022
API-TableView-Swift - API call with URLSession and show data to TableView with swift

API-TableView-Swift API call with URLSession and show data to TableView with swi

Aman Ullah Akhand 1 Sep 3, 2022
Swift library to support collapsible sections in a table view.

CollapsibleTableSectionViewController A Swift library that helps you collapse table view sections. Features Support collapsible sections in a table vi

Su 349 Dec 18, 2022
Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.

Easy to implement controller with expanding menu items. Design is very similar to iOS native ActionSheet presentation style of a UIAlertController. As

Anatoliy Voropay 22 Dec 27, 2022
iOS library - UIScrollView driven expandable menu.

UIScrollView driven expandable menu. Description AirBar is a library for creating cool expandable menus. Library observes UIScrollView scroll and prov

Uptech 625 Nov 8, 2022
Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer. Expandable bottomsheet. Slide out bottom menu

Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer Features It does not re-render the background content while manipulating with the sheet iOS and

Igor 8 Nov 18, 2022
Customizable and easy to use expandable button in Swift.

ExpandableButton Requirements iOS 9.0+ Installation CocoaPods: Add the following line to your Podfile: pod 'ExpandableButton' #for swift less than 4.

Dmytro Mishchenko 98 Dec 5, 2022
Make your table view expandable just by implementing one method.

ExpyTableView About ExpyTableView is a re-write based on SLExpandableTableView. Takes some ideas, concepts and codes and regenerates them in Swift. Le

Okhan Okbay 359 Dec 27, 2022
UITableView based component designed to display a hierarchy of expandable/foldable comments.

SwiftyComments UITableView based component designed to display a hierarchy of expandable/foldable comments. Installation Manually Just copy the .swift

Stéphane Sercu 220 Dec 22, 2022
RHPreviewCell - I envied so much Spotify iOS app this great playlist preview cell 😍

I envied so much Spotify iOS app this great playlist preview cell ??, I decided to create my own one ??. Now you can give your users ability to quick check what content is hidden under your UITableViewCell. Great think is that this Library not requires 3D Touch support from user device??.

Robert Herdzik 387 Sep 23, 2022
AtomicReferenceCell - Atomic Reference Cell (Arc) for Swift

Atomic Reference Cell This project provide two structures: Arc<T> and WeakArc<T>

cjw 0 Jan 30, 2022