@@ -52,6 +52,7 @@ final class CardPresentPaymentsModalViewController: UIViewController, CardReader
5252 setButtonsActions ( )
5353 styleContent ( )
5454 populateContent ( )
55+ observeTraitChanges ( )
5556 }
5657
5758 func setViewModel( _ newViewModel: CardPresentPaymentsModalViewModel ) {
@@ -62,13 +63,18 @@ final class CardPresentPaymentsModalViewController: UIViewController, CardReader
6263 }
6364 }
6465
65- override func traitCollectionDidChange( _ previousTraitCollection: UITraitCollection ? ) {
66- super. traitCollectionDidChange ( previousTraitCollection)
67- resetHeightAndWidth ( )
66+ private func observeTraitChanges( ) {
67+ let traits : [ UITrait ] = [
68+ UITraitVerticalSizeClass . self,
69+ UITraitHorizontalSizeClass . self
70+ ]
71+ registerForTraitChanges ( traits) { ( self : Self, _) in
72+ self . resetHeightAndWidth ( )
73+ }
6874 }
6975
7076 private func resetHeightAndWidth( ) {
71- if traitCollection. containsTraits ( in : UITraitCollection ( verticalSizeClass: . compact) ) {
77+ if traitCollection. verticalSizeClass == . compact {
7278 primaryActionButtonsStackView. axis = . horizontal
7379 primaryActionButtonsStackView. distribution = . fillProportionally
7480
@@ -92,7 +98,7 @@ final class CardPresentPaymentsModalViewController: UIViewController, CardReader
9298 }
9399
94100 private func updateImageAndLoadingVisibility( ) {
95- if traitCollection. containsTraits ( in : UITraitCollection ( verticalSizeClass: . compact) ) {
101+ if traitCollection. verticalSizeClass == . compact {
96102 imageView. isHidden = true
97103 loadingView? . isHidden = true
98104 } else {
0 commit comments