how to use the reuse cell

  • register cell into TableView
  • someone(normally parent ViewController) conform UITableViewDatasource
  • someone(normally parent ViewController) implement DataSource tableView.dataSource = self // example
  • in the datasource, get cell based on reuseIdentify, update cell from model

custom cell/dynamic cell

  • xib custom cell (Atuolayout & constrains)
  • storyboard custom cell
  • create custom cell programmingly (frame based)
  • create custom cell programmingly (Autolayout & constrains)
 // if we use xib+class, must use nib

 // register cell
 let nib = UINib(nibName: CellId, bundle: nil)
 self.tableView.register(nib, forCellReuseIdentifier: CellId)

 self.tableView.register(_ cellClass: AnyClass?, forCellReuseIdentifier: String)

 // register footer or header
 self.tableView.register(_ nib: UINib?, forHeaderFooterViewReuseIdentifier: String)
 self.tableView.register(_ aClass: AnyClass?, forHeaderFooterViewReuseIdentifier: String)

results matching ""

    No results matching ""