Skip to content

Commit

Permalink
fixed UI breaking on device rotation (#330)
Browse files Browse the repository at this point in the history
Co-authored-by: Shresth Pratap Singh <[email protected]>
  • Loading branch information
ShresthPratapSingh and Shresth Pratap Singh authored Jul 29, 2020
1 parent c0ce1ed commit a24fb30
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class WalkthroughViewController: BaseUIViewController {
arrowButton.imageView?.contentMode = .scaleAspectFit
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
collectionView.frame.size = size
collectionView.collectionViewLayout.invalidateLayout()
collectionView.scrollToItem(at: IndexPath(row: pageControl.currentPage, section: 0), at: .centeredHorizontally, animated: false)
}

@IBAction func skipTapped(_ sender: Any) {
showLogin()
}
Expand Down Expand Up @@ -87,13 +93,5 @@ extension WalkthroughViewController: UICollectionViewDelegate, UICollectionViewD
collectionView.backgroundColor = .clear
}
}

override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
collectionView.collectionViewLayout.invalidateLayout()

DispatchQueue.main.async {
self.collectionView.scrollToItem(at: IndexPath(item: self.pageControl.currentPage, section: 0), at: .centeredHorizontally, animated: true)
}
}
}

0 comments on commit a24fb30

Please sign in to comment.