iOS UITableViewAutomaticDimension RowHeight性能差/跳跃

我在iOS 8上构build了一个基本的桌面视图。我观看了关于自动调整单元格的WWDC 14video,并试图重现这个概念,但是遇到了一些问题。 在viewDidLoad:我在打电话:

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

当我的观点和表格加载,性能是好的。 当我点击一个单元格时,程序会带我到一个详细视图。 当我点击该视图上的后退button并返回到表格视图时,这就是事情开始变得怪异的时候。 当我滚动时,单元格开始“跳跃”。 通过跳跃,我的意思是说,他们不顺利滚动 – 他们往往会从一个地方跳到下一个。

我应该补充说,内存不是一个问题,因为这些单元正在被重用,后台的数据很less。 我的单元格(在故事板文件中)的约束也是蓝色的,我在debugging器中看到没有自动布局约束例外。

有没有其他人看到这种行为与UITableViewAutomaticDimension ? 这只是一个苹果的错误,还是有更多的? 谢谢。

我发现奇怪的问题使用行self.tableView.rowHeight = UITableViewAutomaticDimension;

但是,当我用代表方法取代它时,一切都变得更好了。 在你的情况是:

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

在代码中添加一个委托方法

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

它会比当前时间早加载uitableView。 我希望这会为你工作。