How to prevent UITableView from reuse custom cells Swift

前端 未结 4 1969
醉梦人生
醉梦人生 2021-01-02 05:43

In my App I use UITableView with custom cells.

for each cell I implement function to create it, and call these functions in cellFo

4条回答
  •  旧时难觅i
    2021-01-02 06:04

    Try using a different identifier for each of the cell types, so dont use "text-field-cell" for each one, make one "full name", "password" etc. not sure how you are going about creating your cells, but if you are using the registerNib or registerClass, you will need to register it for each different identifier

    self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "full name")
    self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "password")
    self.tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "email")
    

提交回复
热议问题