0

Is it possible for tableview to skip an indexPath in cellForRowAt delegate? My logic is based on that the indexPath will always be incremented by one (because there will always be one cell on the screen). Should I change my logicterminal screenshot?

Status is 1 or -1 based on the scroll direction. but it should never change to 2 which you can see in the second last line.

Hassan Khan
  • 142
  • 1
  • 9
  • indexpath is uniform – Jawad Ali May 12 '20 at 08:02
  • it always increment by 1 – Jawad Ali May 12 '20 at 08:03
  • so what could be the reason? and It didn't happen only one time it keeps happening. – Hassan Khan May 12 '20 at 08:04
  • 2
    It is very difficult to say what the issue is as you haven't shown the code that produces this output. It is important to note that you should never rely on the order in which `cellForRow` will be called in relation to the `indexPath`. It is perfectly normal and possible for it to be called for row 4 and then for row 6. – Paulw11 May 12 '20 at 08:08
  • 1
    Depending on what you are trying to achieve `willDisplayCell` might be a better delegate call to use. – Paulw11 May 12 '20 at 08:11
  • @Paulw11 oh indexPath.row can be incremented by 2. Actually I am saving the old indexPath every time the cellForRow is called. I noticed when there is a difference of two in between these two variables. – Hassan Khan May 12 '20 at 08:14
  • you are saying that in willDisplayCell indexPath will always be incremented by 1? – Hassan Khan May 12 '20 at 08:15
  • 1
    It's not that it can be incremented by two, as such. It is that each call to that method should be considered a separate event and you should not rely on any specific order to those calls – Paulw11 May 12 '20 at 08:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/213675/discussion-between-paulw11-and-hassan-khan). – Paulw11 May 12 '20 at 08:15

0 Answers0