AEAccordion icon indicating copy to clipboard operation
AEAccordion copied to clipboard

Expand only one cell?

Open jboteros opened this issue 7 years ago • 6 comments

@tadija Is it possible to expand only one cell and automatically close the previously expanded cell (if there is one)?

Thanks!!!

jboteros avatar Jul 25 '17 20:07 jboteros

open func toggleCell(_ cell: AccordionTableViewCell, animated: Bool) {
    if cell.expanded {
        collapseCell(cell, animated: animated)
    } else {
        if expandedIndexPaths.count > 0 {
            for i in 0 ..< expandedIndexPaths.count {
                if let cellPath = tableView.cellForRow(at: self.expandedIndexPaths[i]) {
                    collapseCell(cellPath as! AccordionTableViewCell, animated: animated)
                }
            }
        }
        expandCell(cell, animated: animated)
    }
}

Edit AccordionTableViewController.swift

👍

iStorry avatar Aug 02 '17 07:08 iStorry

There's no built in way for this, but might be a good idea for enhancement.

tadija avatar Nov 25 '17 21:11 tadija

collapseCell and expandCell throw

'collapseCell' is inaccessible due to 'private' protection level

Nachot93 avatar May 20 '19 12:05 Nachot93

Hello?

Nachot93 avatar May 28 '19 17:05 Nachot93

@Nachot93 please follow this

open func toggleCell(_ cell: AccordionTableViewCell, animated: Bool) {
    if cell.expanded {
        collapseCell(cell, animated: animated)
    } else {
        if expandedIndexPaths.count > 0 {
            for i in 0 ..< expandedIndexPaths.count {
                if let cellPath = tableView.cellForRow(at: self.expandedIndexPaths[i]) {
                    collapseCell(cellPath as! AccordionTableViewCell, animated: animated)
                }
            }
        }
        expandCell(cell, animated: animated)
    }
}

Edit AccordionTableViewController.swift

👍

iStorry avatar May 29 '19 12:05 iStorry

@Nachot93 you can change function to public or open

https://github.com/tadija/AEAccordion/blob/master/Sources/AEAccordion/AccordionTableViewController.swift#L98

https://github.com/tadija/AEAccordion/blob/master/Sources/AEAccordion/AccordionTableViewController.swift#L72

iStorry avatar May 29 '19 23:05 iStorry