6

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.

AlvaroAV
  • 10,335
  • 12
  • 60
  • 91
Brian Sachetta
  • 3,319
  • 2
  • 34
  • 45
  • I'm facing same issue? any workaround? – Ahmad Raza Jan 02 '15 at 12:04
  • @AhmadRaza What I ended up doing was going back to hand coded cells to ensure full control over layout and function. So basically, instead of using interface builder, I just lay out all the elements of the cell in code and then override tableView:heightForRowAtIndexPath: to tell the tableView how tall each cell will be. – Brian Sachetta Jan 02 '15 at 16:10
  • 1
    I filed a bug with apple (over this behavior) and they confirmed that it was a bug (and a duplicate of one already filed) but did not provide any more information than that (pretty annoying). So I am assuming UITableViewAutomaticDimesion is known to be a bit buggy. I'd avoid it if possible for now. – Brian Sachetta Jan 02 '15 at 16:14
  • I've implemented the example from WWDC2014 to demonstrate this issue, it's available here: https://github.com/IndieGoGo/WWDC-Dynamic-Type-Jumpy-Scroll-Issue Also filed a bug with no response. – jan Feb 03 '15 at 19:27

3 Answers3

6

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;
}
0

ADD one more delegate method to the code

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

it will load uitableView early than current time. i hope this will work for you.

Yogesh More
  • 239
  • 3
  • 4
0

In cellForRowAtIndexPath add below line

cell.textLabel.numberOfLines = 0;
umakanta
  • 1,051
  • 19
  • 25