How to prevent UITableView from reuse custom cells Swift

前端 未结 4 1977
醉梦人生
醉梦人生 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条回答
  •  醉话见心
    2021-01-02 06:09

    You shouldn't prevent that, but if you really want to, I think that not setting cell identifier to your UITableViewCell should do the trick. When you'll call dequeueReusableCellWithIdentifier, it will find no cell and will create a new one. But again, it's not recommended as UITableView is made to be used with reuse ability.

    Moreover, as @Fonix suggests, using a different cell identifier for each cell of your UITableView might solve your issue while keeping using cell reuse system.

    Edit : As you're talking about losing text content in your UITextField, maybe the single change to make is changing your @propery weak attribute to strong.

    Hope this helps.

提交回复
热议问题