Skip to content

Commit 2dd4d6f

Browse files
committed
fix(iOS): wrong orientation value type provided to the right method
1 parent 4af34de commit 2dd4d6f

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

ios/implementation/OrientationDirectorImpl.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

ios/implementation/Utils.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)