Skip to content

Commit 5e178f8

Browse files
authored
fix(iOS): iOS 15 doesn't lock the interface using provided methods (#76)
1 parent f1e68a3 commit 5e178f8

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ PODS:
13321332
- React-jsiexecutor
13331333
- React-RCTFBReactNativeSpec
13341334
- ReactCommon/turbomodule/core
1335-
- react-native-orientation-director (2.4.0):
1335+
- react-native-orientation-director (2.5.0):
13361336
- DoubleConversion
13371337
- glog
13381338
- hermes-engine
@@ -2076,7 +2076,7 @@ SPEC CHECKSUMS:
20762076
React-logger: 368570a253f00879a1e4fea24ed4047e72e7bbf3
20772077
React-Mapbuffer: c04fcda1c6281fc0a6824c7dcc1633dd217ac1ec
20782078
React-microtasksnativemodule: ca2804a25fdcefffa0aa942aa23ab53b99614a34
2079-
react-native-orientation-director: 2dd845aa5c3a30c143f43103b30e6dcc0b0e9048
2079+
react-native-orientation-director: 6d154528f2f6aad982161d0824fcd175a18b79bd
20802080
react-native-safe-area-context: 00d03dc688ba86664be66f9e3f203fc7d747d899
20812081
React-NativeModulesApple: 452b86b29fae99ed0a4015dca3ad9cd222f88abf
20822082
React-oscompat: ef5df1c734f19b8003e149317d041b8ce1f7d29c

ios/implementation/OrientationDirectorImpl.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ import UIKit
155155
print("\(OrientationDirectorImpl.TAG) - requestGeometryUpdate error", error)
156156
}
157157
} else {
158-
UIDevice.current.setValue(mask.rawValue, forKey: "orientation")
158+
let interfaceOrientation = self.utils.convertToInterfaceOrientationFrom(mask: mask)
159+
UIDevice.current.setValue(interfaceOrientation.rawValue, forKey: "orientation")
159160
UIViewController.attemptRotationToDeviceOrientation()
160161
}
161162
}

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)