Strange behaviour on table view with core data

前端 未结 2 1286
时光说笑
时光说笑 2021-01-28 17:00

step by step I am advancing creating my first iOS app. Now I am experiencing a strange behaviour on a table view controller which I am not able to solve and I have been searchin

2条回答
  •  梦谈多话
    2021-01-28 17:19

    Your problem appears to be in the configureCell: method. You are not taking cell reuse into account. The cell you are configuring could have need used before and could have had an urgent status previously.

    Your code only deals with the situation where the cell is urgent, in which case it adds a subview. There are two problems with this approach:

    1. A reused cell will have the subview added every time - so there could be many urgent views on top of each other. The cell should only ever add this once and keep it in a property
    2. Code must be added to configure the cell when it is not urgent (usually, an else after the if). This would hide the urgent icon.

提交回复
热议问题