delegate and datasource methods for UITableView

后端 未结 12 1663
礼貌的吻别
礼貌的吻别 2020-12-13 00:50

Can anyone list delegate methods and data source methods for UITableView?

Are delegates and data sources methods are same for UITableView?<

12条回答
  •  感动是毒
    2020-12-13 01:35

    //Delegate & DataSource method Deferent.

    //Swift 4.1

    UITableViewDataSource: // below two method required

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

    //Optional

    func numberOfSections(in tableView: UITableView) -> Int

    func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?

    func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String?

    //row Edit

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool

    func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool

    // Index

    func sectionIndexTitles(for tableView: UITableView) -> [String]?

    func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int

    // Row Insert or Delete

    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)

    func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath)

    //UITableViewDelegate //Row, header, Footer height

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat

    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat

    // Row Selected

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

    func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)

提交回复
热议问题