YJTableModelDriver
Example
- To run the example project, clone the repo, and run
pod install
from the Example directory first. Row
实现RowConvertable
协议 ,Section
实现SectionConvertable
协议
let row1 = Row.nibRow(cellClass: MyTableViewCell.self)
row1.didSelectAt { (table, index) in
print("index = \(index.row)")
}
row1.tableHeight { () -> CGFloat in
return 100
}
let row2 = Row.nibRow(cellClass: TestTableViewCell.self)
let section = Section(rows: [row1,row2])
section.tableHeaderView { (_, _) -> UIView? in
let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 100))
view.backgroundColor = UIColor.red
return view
}
section.tableHeaderViewHeight { (_, _) -> CGFloat in
return 100
}
//初始化
let modelDriver = YJTableModelDriver(sections: [section])
tableView.modelDriver = modelDriver
UITableViewCell
数据绑定,需要实现BindCellableProtocol
协议
class TestTableViewCell: UITableViewCell,BindCellableProtocol {
func bindViewWithData(data: Any) {
guard let row = data as? Row else { return }
print(row)
}
}
Requirements
Installation
YJTableModelDriver is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'YJTableModelDriver'
Author
full-of-fire, [email protected]
License
YJTableModelDriver is available under the MIT license. See the LICENSE file for more info.