AZExpandable 是 UITableView 的轻量级代理,用于扩展单元格。它将原生 NSProxy 机制封装在内,并向外部提供便捷的 API。
一般优势:无需子类化,无需代码混淆,易于集成
示例
要求
- iOS 8.0+
- Xcode 9.2+
- Swift 4.0+
通信
- 如果你想要 提问一个一般性的问题,使用 Twitter。
- 如果你 发现了错误,打开一个问题。
- 如果你 有功能请求,打开一个问题。
- 如果你 想要做出贡献,提交一个拉取请求。
安装
CocoaPods
CocoaPods 是 Cocoa 项目的一个依赖管理器。你可以使用以下命令安装它
$ gem install cocoapods
需要 CocoaPods 1.1 或更高版本来构建 AZExpandable。
要使用 CocoaPods 将 AZExpandable 集成到你的 Xcode 项目中,请在你的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target '<Your Target Name>' do
pod 'AZExpandable'
end
然后,运行以下命令
$ pod install
使用方法
private var expandableTable: ExpandableTable!// Expanding Table Proxy
override func viewDidLoad() {
super.viewDidLoad()
// infoProvider - UITableViewDelegate & UITableViewDataSource
expandableTable = ExpandableTable(with: tableView, infoProvider: self)
}
func expandCell(at indexPath: IndexPath) {
let cellClosure: CellClosure = { (IndexPath) -> (UITableViewCell) in
//Your custom expanding cell
return self.tableView.dequeueReusableCell(withIdentifier: "Identifier", for: indexPath)
}
expandableTable.expandCell(ExpandedCellInfo(for: indexPath, cellType: .custom(cellClosure)))
}
func unexpandCell() {
expandableTable.unexpandCell()
}
授权信息
AZExpandable 采用 MIT 授权发布。有关详细信息,请参阅 LICENSE 文件。