File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import UIKit
1919 private var lastInterfaceOrientation = Orientation . UNKNOWN
2020 private var lastDeviceOrientation = Orientation . UNKNOWN
2121 private var isLocked = false
22-
22+
2323 /// # Only on iOS < 16
2424 /// This variable is needed to prevent a loop where
2525 /// we lock the interface to a specific orientation
@@ -166,18 +166,19 @@ import UIKit
166166 print ( " \( OrientationDirectorImpl . TAG) - requestGeometryUpdate error " , error)
167167 }
168168 } else {
169- UIDevice . current. setValue ( mask. rawValue, forKey: " orientation " )
169+ let interfaceOrientation = self . utils. convertToInterfaceOrientationFrom ( mask: mask)
170+ UIDevice . current. setValue ( interfaceOrientation. rawValue, forKey: " orientation " )
170171 UIViewController . attemptRotationToDeviceOrientation ( )
171172 }
172173 }
173174
174175 private func onOrientationChanged( uiDeviceOrientation: UIDeviceOrientation ) {
175176 let deviceOrientation = utils. convertToOrientationFrom ( deviceOrientation: uiDeviceOrientation)
176-
177+
177178 if ( !self . isLocking) {
178179 self . eventManager. sendDeviceOrientationDidChange ( orientationValue: deviceOrientation. rawValue)
179180 }
180-
181+
181182 lastDeviceOrientation = deviceOrientation
182183 adaptInterfaceTo ( deviceOrientation: deviceOrientation)
183184 }
Original file line number Diff line number Diff line change @@ -78,6 +78,21 @@ class Utils {
7878 }
7979 }
8080
81+ public func convertToInterfaceOrientationFrom( mask: UIInterfaceOrientationMask ) -> UIInterfaceOrientation {
82+ switch mask {
83+ case . portrait:
84+ return . portrait
85+ case . landscapeRight:
86+ return . landscapeRight
87+ case . portraitUpsideDown:
88+ return . portraitUpsideDown
89+ case . landscapeLeft:
90+ return . landscapeLeft
91+ default :
92+ return . unknown
93+ }
94+ }
95+
8196 public func getInterfaceOrientation( ) -> UIInterfaceOrientation {
8297 guard let windowScene = self . getCurrentWindow ( ) ? . windowScene else {
8398 return UIInterfaceOrientation . unknown
You can’t perform that action at this time.
0 commit comments