Fully refactored YNExapnadableCell with more concise, bug free. Easiest usage of expandable & collapsible cell for iOS, written in Swift 3. You can customize expandable UITableViewCell
whatever you like. ExpandableCell
is made because insertRows
and deleteRows
is hard to use. Just inheirt ExpandableDelegate
ExpandableCell
written in Swift 3. Compatible with iOS 8.0+
ExpandableCell is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ExpandableCell'
github "younatics/ExpandableCell"
import ExpandableCell
Make ExpandableTableView
in Storyboard or in code
@IBOutlet var tableView: ExpandableTableView!
Inherit ExpandableDelegate
class ViewController: UIViewController, ExpandableDelegate
Set delegate
tableView.expandableDelegate = self
Set required ExpandableDelegate
method.
Set expandedCells
and height in these two methods. Pass one parameter when you need to expand only one cell
func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]?
func expandableTableView(_ expandableTableView: ExpandableTableView, heightsForExpandedRowAt indexPath: IndexPath) -> [CGFloat]?
Set common UITableViewDataSource
, UITableViewDelegate
method
func expandableTableView(_ expandableTableView: ExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
func expandableTableView(_ expandableTableView: ExpandableTableView, numberOfRowsInSection section: Int) -> Int
func expandableTableView(_ expandableTableView: ExpandableTableView, heightForRowAt indexPath: IndexPath) -> CGFloat
Set optional ExpandableDelegate
method.
func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectRowAt indexPath: IndexPath)
func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCell: UITableViewCell, didSelectExpandedRowAt indexPath: IndexPath)
func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectExpandedRowAt indexPath: IndexPath)
func expandableTableView(_ expandableTableView: ExpandableTableView, titleForHeaderInSection section: Int) -> String?
func expandableTableView(_ expandableTableView: ExpandableTableView, heightForHeaderInSection section: Int) -> CGFloat
func expandableTableView(_ expandableTableView: ExpandableTableView, viewForHeaderInSection section: Int) -> UIView?
func numberOfSections(in expandableTableView: ExpandableTableView) -> Int
func expandableTableView(_ expandableTableView: ExpandableTableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
func expandableTableView(_ expandableTableView: ExpandableTableView, willDisplayHeaderView view: UIView, forSection section: Int)
func expandableTableView(_ expandableTableView: ExpandableTableView, willDisplayFooterView view: UIView, forSection section: Int)
Inherit ExpandableCell
when you need arrow effect or change arrow image
open class ExpandableCell: UITableViewCell {
open var arrowImageView: UIImageView!
}
Use collapse all function
tableView.closeAll()
Make protocols in ExpandableDelegate
if you need or make pull request to me :)
ExpandableCell is available under the MIT license. See the LICENSE file for more info.