In this project I am populating a table with data from a web service. The table reloads as more data becomes available. I am using heightForRowAtIndexPath
to size the cell according the size of the title string. It returns the MAX of 54 or string height. The strange thing is that the first time that the table runs through the load sequence it returns 44 for every cell. I log the cell height in cellForRowAtIndexPath
. When reload is called a second time I get the correct cell heights. The result is that the cells subviews are out of place initially then put in place very abruptly. Wondering if anyone has any insights about UITableView
that may point me in the right direction. Thanks!
Asked
Active
Viewed 414 times
0

onkar
- 4,427
- 10
- 52
- 89

Gabriel Ortega
- 481
- 5
- 18
-
Found answer here: http://stackoverflow.com/questions/11898596/uitableviewcell-frame-height-not-matching-tableviewheightforrowatindexpath?rq=1 – Gabriel Ortega Dec 19 '12 at 01:18
1 Answers
1
You have to store size of string before calling reload in a member variable since the string got first so it will be easier, the next thing is to return that member variable in height for row at indexPath method;
@interface
{
CGSize fixedStringSize;
}
@implementation
-(void)dataFinishDownload
{
fixedStringSize = [yourCustomMethodForStringSize:titleString];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return fixedStringSize.height;
}
@end

funmania
- 71
- 2