IOS UITableViewAutomaticDimension RowHeight Poor Performance / Jumping

I am creating a basic table view on iOS 8. I watched a WWDC '14 video on cell auto-negotiation and try to reproduce the concept, but I have some problems. In viewDidLoad: I call:

//estimate for my cells though they may vary self.tableView.estimatedRowHeight = 300.0; self.tableView.rowHeight = UITableViewAutomaticDimension; 

When my view and table load, performance is fine. When I click on a cell, the program displays me in a detailed view. When I click the back button on this view and return to the table view, this is when things start acting weird. Then the cells start to “jump” while I scroll. When jumping, I mean that they do not scroll smoothly - they tend to jerk or jump from one place to another.

I should add that memory is not a concern, as the cells are reused and there is little data in the background. The restrictions on my cells (in the storyboard file) are also blue, and there are no autodetection restrictions exceptions in the debugger.

Has anyone else seen this behavior with a UITableViewAutomaticDimension ? Is this just Apple's mistake or is there more? Thanks.

+5
source share
3 answers

I found a strange problem using the line self.tableView.rowHeight = UITableViewAutomaticDimension;

But then things got much better when I replaced it with the delegate method. In your case, it will be:

 - (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewAutomaticDimension; } - (CGFloat) tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath { return 300.0f; } 
+5
source

ADD another delegate method to code

- (CGFloat) tableView: (UITableView *) tableView estimated HeightForRowAtIndexPath: (NSIndexPath *) indexPath {return Approxheight;}

it will load the uitableView before the current time. I hope this works for you.

0
source

In cellForRowAtIndexPath add the line below

 cell.textLabel.numberOfLines = 0; 
0
source

Source: https://habr.com/ru/post/1206833/


All Articles