YJTableModelDriver 1.0.2

YJTableModelDriver 1.0.2

Maintained by yangjie.



  • By
  • full-of-fire

YJTableModelDriver

CI Status Version License Platform

Example

  1. To run the example project, clone the repo, and run pod install from the Example directory first.
  2. 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
  1. 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.