iOS 8自动单元格高度 – didSelectRowAtIndexPath导致UItableview跳转到顶部

我目前正在更新一个应用程序到iOS8,并取代我自己的单元格高度计算。 我有一堆自定义单元格的tableview。 每个单元格被选中时,都会在navigationController上显示/推送一个新的视图。 当tableview被填充这些单元格,并且用户select一个靠近表格底部时,tableview在新的视图出现之前跳转到右上angular。 这对用户来说很分散。 我正在尝试使用iOS 8中引入的自定义单元格(在viewDidLoad中):

self.tableView.estimatedRowHeight = 60.0; self.tableView.rowHeight = UITableViewAutomaticDimension; 

这里是select单元格的代码

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIViewController *selectedViewController = [[UIStoryboard storyboardWithName:@"Trip" bundle:nil] instantiateViewControllerWithIdentifier:@"TripDetail"]; DetailViewController *destViewController = (id)selectedViewController; [destViewController setData:self.dataStore]; [self.navigationController pushViewController:selectedViewController animated:YES]; } 

有谁知道这是为什么发生? 而我怎么能使它停止?

这是一个已知的问题。 tableView正在调用它的委托来估计行的高度,这导致表格滚动。

你可以等待下一次更新是否被修复,或者实现tableView:estimatedHeightForRowAtIndexPath:作为现在的解决方法)并返回一个caching的高度。 由于估计将是实际的高度,所以桌子不会跳跃。

发生这种情况时,表代表被轻敲“didSelectRowAtIndexPath:”,因为委托方法“numbersOfSectionsInTableView”&&“numbersOfRowsInSection”将被调用。 它喜欢重新加载表。

你可以用这个方法“heightForRowAtIndexPath:”修复这个跳跃状态,但是你必须忽略你的自动resize。