views:

77

answers:

1

I've got an iPad app with a UITableView that has roughly 100 rows. The cells are custom, I've implemented heightForRowAtIndexPath to tell the UITableView how big my cells are.

I'm using this:

   [tableView scrollToRowAtIndexPath:indexPath 
              atScrollPosition:UITableViewScrollPositionMiddle animated:NO];

to scroll the table to a given row. This works perfectly for row 1-75. Row 76 is slightly off the middle, 76-79 are slightly more off, and as of row 80, it no longer scrolls to the correct position at all. It just stays put with row 79 being the last visible row. I can still manually scroll the table by dragging my finger when this happens; it's observably not yet at the end. It seems however that programmatically, scrollToRowAtIndexPath thinks it has reached the end of the table before it actually has. I would expect this behaviour at the end of the table, not at 3/4 of the rows.

I am struggling to debug what is happening here; I would appreciate any pointers that help me find out why the table is thinking it is already at the end when I call scrollToRowAtIndexPath.

A: 

You write you have overridden heightForRowAtIndexPath:, but there is nothing to override. You should have a delegate that implements the UITableViewDelegate protocol, to be called by the tableView.

If that is already the case, you should check that your delegate is correctly working by logging the values in heightForRowAtIndexPath is called, or break in there.

w.m
Yes, sorry that's what I meant; the height function is called and the value is correct (which I can also tell from the cells; they are all rendered properly).
Ivo Jansch