Skip to main content
 首页 » 操作系统

iOS 8 UITableView 单元格在选中时跳转

2024年01月01日41powertoolsteam

我有一个非常标准的 UITableView,它使用自动调整单元格的大小

// Set the height of the table view cells 
self.tableView.rowHeight = UITableViewAutomaticDimension; 
self.tableView.estimatedRowHeight = 44.0; 

当我将 segue 推送到新的 View Controller 时, TableView 跳转到不同的位置。我试过 estimatedRowHeight、rowHeight,使用 tableView 方法,但没有...

我已经阅读了这些内容,但仍然没有任何效果。有人吗?

• Table View Cells jump when selected on iOS 8

• iOS 8 Auto cell height - didSelectRowAtIndexPath causes UItableview to jump to top

• IOS 8 UITableView self-sizing cells jump/shift visually when a new view controller is pushed

请您参考如下方法:

这是一个已知问题。

我相信您会发现 estimatedRowHeight 与实际高度的差异越大,当 push segue 发生时表格跳动的幅度就越大。解决方法是使用更好的估计值(或实现 tableView:estimatedHeightForRowAtIndexPath: 并返回准确的高度)。