Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UITableViewAutomaticDimension RowHeight Poor Performance / Jumping

I'm building a basic table view on iOS 8. I watched the WWDC '14 video on the topic of autosizing cells and am trying to reproduce the concept, but am having some issues. On viewDidLoad: I am calling:

//estimate for my cells though they may vary

self.tableView.estimatedRowHeight = 300.0;

self.tableView.rowHeight = UITableViewAutomaticDimension;

When my view and table load up, performance is ok. When I click on a cell, the program takes me to a detail view. When I hit the back button on that view and return to the table view, that's when things start acting weird. The cells then start 'jumping' while I am scrolling. By jumping I mean that they don't scroll smoothly - they tend to jerk or jump from one place to the next.

I should add that memory is not a concern since the cells are being reused and there is little data in the background. The constraints on my cells (in storyboard file) are also blue and I am seeing no autolayout constraint exceptions in the debugger.

Has anyone else seen this kind of behavior with UITableViewAutomaticDimension? Is it just an Apple bug or is there more to it? Thanks.

like image 308
Brian Sachetta Avatar asked Nov 13 '14 20:11

Brian Sachetta


1 Answers

I have found weird issue using the line self.tableView.rowHeight = UITableViewAutomaticDimension;

But then, everything came a lot better when I replaced it with the delegates method. In your case would be :

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}

- (CGFloat) tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 300.0f;
}
like image 190
Marc-Alexandre Bérubé Avatar answered Nov 03 '22 13:11

Marc-Alexandre Bérubé