Latest 2.0.1
Homepage https://github.com/gitkong/FLTableViewComponent
License MIT
Platforms ios 8.0, requires ARC
Authors

FLTableComponent for tableView and collectionView

Introduce

A component for tableView and collectionView, which can greatly reduce your controller codes, also, you can set header or footer more easily

Requirements

swift3+ and xcode8+

Installation

pod "FLTableComponent"

How To Use (Just give an example for tableView)

  1. Create a controller which inherit the class of FLTableComponentController
class DemoViewController: FLTableComponentController {

}
  1. Create a component which inherit of FLTableBaseComponent, and override some methods
class DemoComponent: FLTableBaseComponent {

  override func cellForRow(at indexPath: IndexPath) -> UITableViewCell {
    let cell : UITableViewCell = super.cellForRow(at: indexPath)
    return cell
}

  override func numberOfRows() -> NSInteger {
      return 2
  }

  ...

}
  1. set dataSource in controller

var arr : Array<FLTableBaseComponent> = []

let component = DemoComponent.init(tableView: self.tableView)
let NibComponent = NibDemoComponent.init(tableView: self.tableView)

arr.append(component)
arr.append(NibComponent)
self.components = arr

Custom Use

  1. custom tableView style and rect
override var tableViewStyle: UITableViewStyle {
  return UITableViewStyle.grouped
}

override func customRect() -> CGRect {
  return self.view.bounds
}
  1. override the method of register() to regist custom cell、header or footer
override func register() {
  // if you need default register, call super
  //super.register()
  // regist your custom cell、header or footer
}
  1. create custom header or footer for cell

override func 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
}

override func 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
}

override func heightForHeader(at section: Int) -> CGFloat {
  // return height for header
}

override func footerView(at section: Int) -> FLTableViewHeaderFooterView? {
  // the same as header
}

override func additionalOperationForReuseFooterView(_ footerView: FLTableViewHeaderFooterView?) {
  // the same as header
}

override func heightForFooter(at section: Int) -> CGFloat {
    // return height for footer
}
  1. custom header or footer of tableView
override func headerView(of tableView: UITableView) -> UIView? {
  // return tableHeaderView
}

override func footerView(of tableView: UITableView) -> UIView? {
  // return tableFooterView
}

Author

[email protected]简书My blog

Thanks

rickytan RTComponentTableView(Objective-C)

License

FLTableComponent is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "FLTableComponent",
    "version": "2.0.1",
    "summary": "A component for tableView and collectionView",
    "description": "A component for tableView and collectionView, which can greatly reduce your controller codes, also, you can set header or footer more easily",
    "homepage": "https://github.com/gitkong/FLTableViewComponent",
    "license": {
        "type": "MIT",
        "file": "FILE_LICENSE"
    },
    "authors": {
        "gitKong": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/gitkong/FLTableViewComponent.git",
        "tag": "2.0.1"
    },
    "source_files": "FLTableComponent/**/*",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This