indexpath.row is starting from 1 instead of 0

11,026

Solution 1

tableView:cellForRowAtIndexPath: is called as needed to display a cell, if a cell is not going to be displayed it is not called. If row 0 is not being displayed section-cell 0-0 will not be called.

Solution 2

Like Zaph stated, tableView:cellForRowAtIndexPath: is called whenever a table wants to display a cell for a given index path, so if you're not getting an index path with a row of 0 ever, it means you're likely doing something that prevents that cell from getting shown.

My first suggestion would be to investigate your tableView:heightForRowAtIndexPath: method, and 1) check if it's getting called with an index path row of 0, and 2) make sure something > 0 is being returned.

The fact that you're seeing it on iOS 8 only does not necessarily mean something native is broken, but might instead suggest that some of your logic which contributes to the above methods is affected by iOS 8 changes. iOS 8 had thrown off the way I was doing text size calculations, so perhaps something less obvious like that is resulting in returning a height not greater than 0.

Share:
11,026
ravoorinandan
Author by

ravoorinandan

i phone/i pad application developer.

Updated on August 09, 2022

Comments

  • ravoorinandan
    ravoorinandan almost 2 years

    i am facing a strance issue with a uitableview. sometime when my table's datasource/numberofrowsinsection has 3 values, cellforowatindexpath starts from 0-1 instead of 0-0. can someone help me out finding the possible reasons for this issue to happen. even tried printing the logs but the logs were shown for 0 -1 and 0 -2 but not for 0 -0. That means it is not getting called for the first row i.e 0 -0.