A component for tableView and collectionView, which can greatly reduce your controller codes, also, you can set header or footer more easily
swift3+ and xcode8+,新增Objective-C缩减版本(只针对UITableView)
pod"FLTableComponent"- Create a controller which inherit the class of FLTableComponentController Or Create FLTableViewHandler to handle it, you can check the implementation of FLTableComponentController,and it will show you how to use it
classDemoViewController:FLTableComponentController{}- Create a component which inherit of FLTableBaseComponent, and override some methods
classDemoComponent:FLTableBaseComponent{overridefunc cellForRow(at indexPath:IndexPath)->UITableViewCell{letcell:UITableViewCell= super.cellForRow(at: indexPath)return cell }overridefunc numberOfRows()->NSInteger{return2}...}- set dataSource in controller
vararr:Array<FLTableBaseComponent>=[]letcomponent=DemoComponent.init(tableView:self.tableView)letNibComponent=NibDemoComponent.init(tableView:self.tableView) arr.append(component) arr.append(NibComponent)self.components = arr- custom tableView style and rect
overridevartableViewStyle:UITableViewStyle{returnUITableViewStyle.grouped }overridefunc customRect()->CGRect{returnself.view.bounds }- override the method of register() to regist custom cell、header or footer
overridefunc register(){ // if you need default register, call super //super.register() // regist your custom cell、header or footer }- create custom header or footer for cell
overridefunc headerView(at section:Int)->FLTableViewHeaderFooterView?{ // you should call super to get headerView if you just regist the class of FLTableViewHeaderFooterView; // if you override the method of register() to regist the subclass of FLTableViewHeaderFooterView, you can not call super to get headerView, // and you should call init(reuseIdentifier: String?, section: Int) and addClickDelegete(for headerFooterView : FLTableViewHeaderFooterView?) // if this headerView have to accurate tapping event }overridefunc additionalOperationForReuseHeaderView(_ headerView:FLTableViewHeaderFooterView?){ // do some additional operations, at usual, you add label or button or something else into header view to resue // but if you had registed the class of FLTableViewHeaderFooterView for footerView, this method will be invalid. //so if you want it to be valiable, do not call super when you override register() method }overridefunc heightForHeader(at section:Int)->CGFloat{ // return height for header }overridefunc footerView(at section:Int)->FLTableViewHeaderFooterView?{ // the same as header }overridefunc additionalOperationForReuseFooterView(_ footerView:FLTableViewHeaderFooterView?){ // the same as header }overridefunc heightForFooter(at section:Int)->CGFloat{ // return height for footer }- custom header or footer of tableView
overridefunc headerView(of tableView:UITableView)->UIView?{ // return tableHeaderView }overridefunc footerView(of tableView:UITableView)->UIView?{ // return tableFooterView }rickytan RTComponentTableView(Objective-C)
FLTableComponent is available under the MIT license. See the LICENSE file for more info.

