AEAccordion
AEAccordion copied to clipboard
Expand only one cell?
@tadija Is it possible to expand only one cell and automatically close the previously expanded cell (if there is one)?
Thanks!!!
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
👍
There's no built in way for this, but might be a good idea for enhancement.
collapseCell
and expandCell
throw
'collapseCell' is inaccessible due to 'private' protection level
Hello?
@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
👍
@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