Skip to content

SabrinaJiang14/SJExpandableTableView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SJExpandableTableView

A very simple to use Expandable Table, also could custom header or cell.

Example

Just run the example project, or clone the repo.

Requirements

  • Xcode 12 or above
  • iOS 14
  • Swift 5.2

GITHUB

Basic Usage

The TableView colud be init by code or by IBOutlet,

// IBOutlet
@IBOutlet weak var mainTableView: SJExpandableTableView!

// code init
private lazy var mainTableView:SJExpandableTableView = {
 return SJExpandableTableView(frame: self.view.frame, style: .plain)
}()
  • Example code
// normal status's height
.configureItem(height: 45)

// top title
.configureHeader(titles: ["項目一","項目二","項目三"])

// allow mutilple selected, dafault is false
.configureMultipleCollapse(true)

// conform to the SJExpandableTableDataSource protocol
.configureDelegate(self)

// collapse tableView header
.itemTitleDidSelected { _ in }

// collapse tableView cell
.itemContentDidSelected { _ in }

// need pull refresh
.pullToRefresh(header: { [weak self] in
 //TODO: ...
}, footer: { [weak self]  in
 //TODO: ...
})
// binding data
self.binding.bind(to: mainTableView)

Customized Usage

// register custom cell by nib or class
.configureNibCell(cellIDs: ["TextViewCell"])
.configureClassCell(any: [TextViewCell.self])

// conform the (tableView: cellForRowAt:) protocol 
.configureItemCell { [weak self] (tb, indexPath, headers, contents, selectedIndex) -> UITableViewCell? in
 //TODO: Need return custom cell
 //      and the custom cell should conform **ExpandableItemCellDelegate** if want get cell tap event
}

// conform the (tableView: heightForRowAt:) protocol 
.configureItemCellForHeight { (tb, indexPath, selectedIndex, content) -> CGFloat in
 //TODO: Need return height for cell
}

TODO

  • Refresh with tableView header
  • Collapse all / Expand all

Licence

Licence MIT

About

Collapse table view in swift

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages