简体   繁体   中英

Is it necessary to update the TableView layout on rotation?

When using a collectionView on the iPad and rotating it, I call:

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

    collectionView.collectionViewLayout.invalidateLayout()
}

Is it necessary to do the same thing with a tableView ?

I got the below code from this older answer

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

    tableView.beginUpdates()
    tableView.endUpdates()
}

You don't need update layout when you rotation device. Because tableView will auto adjust cell layout when rotation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM