     public override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
         coordinator.animate(alongsideTransition: { (_) in
             self.headerCollectionView.collectionViewLayout.invalidateLayout()
-            self.headerCollectionView.reloadData()
+            self.contentCollectionView.collectionViewLayout.invalidateLayout()
+            self.selectTab(at: self.selectedIndex)
+        }, completion: nil)
+    }
+    
+    public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        super.viewWillTransition(to: size, with: coordinator)
+        guard isViewLoaded else { return }
+        coordinator.animate(alongsideTransition: { (_) in
             self.headerCollectionView.collectionViewLayout.invalidateLayout()
-            self.contentCollectionView.reloadData()
+            self.contentCollectionView.collectionViewLayout.invalidateLayout()
+            self.selectTab(at: self.selectedIndex)
         }, completion: nil)
     }
 }

        didSet {
            fatalError("Not yet supported")
        }
    }
    
    fileprivate var previousContentOffset = CGPoint(x: 0, y: 0)

            contentCollectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
            ])
        
        reloadData()
        selectTab(at: 0)
    }
    
