旋转时是否需要更新 TableView 布局?

Is it necessary to update the TableView layout on rotation?

当在 iPad 和 rotating 上使用 collectionView 时,我调用:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

    collectionView.collectionViewLayout.invalidateLayout()
}

是否有必要用tableView做同样的事情?

我从这个 older answer

得到了下面的代码
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

    tableView.beginUpdates()
    tableView.endUpdates()
}

旋转设备时不需要更新布局。因为 tableView 会在旋转时自动调整单元格布局。