From 0e9c38274365cf298fd70a114115fb10e62efe2c Mon Sep 17 00:00:00 2001 From: gladius Date: Sun, 26 May 2024 14:23:32 +0200 Subject: [PATCH] fix(iOS): missing check if deviceOrientation is actually supported (#13) --- ios/implementation/OrientationDirectorImpl.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ios/implementation/OrientationDirectorImpl.swift b/ios/implementation/OrientationDirectorImpl.swift index d70b466..acf4f2d 100644 --- a/ios/implementation/OrientationDirectorImpl.swift +++ b/ios/implementation/OrientationDirectorImpl.swift @@ -66,7 +66,7 @@ import UIKit updateIsLockedTo(value: false) self.adaptInterfaceTo(deviceOrientation: deviceOrientation) } - + @objc public func resetSupportedInterfaceOrientations() { self.supportedInterfaceOrientations = self.initialSupportedInterfaceOrientations self.requestInterfaceUpdateTo(mask: self.supportedInterfaceOrientations) @@ -82,7 +82,7 @@ import UIKit guard let firstSupportedInterfaceOrientation = supportedInterfaceOrientations.first else { return } - + let orientation = OrientationDirectorUtils.getOrientationFrom(mask: firstSupportedInterfaceOrientation) self.updateLastInterfaceOrientation(value: orientation) } @@ -155,8 +155,10 @@ import UIKit return } - if (deviceOrientation == Orientation.FACE_UP || deviceOrientation == Orientation.FACE_DOWN) { - return + let deviceOrientationMask = OrientationDirectorUtils.getMaskFrom(orientation: deviceOrientation) + let isDeviceOrientationMaskSupported = self.supportedInterfaceOrientations.contains(deviceOrientationMask) + if (!isDeviceOrientationMaskSupported) { + return } updateLastInterfaceOrientation(value: deviceOrientation) @@ -166,7 +168,7 @@ import UIKit eventManager.sendLockDidChange(value: value) isLocked = value } - + private func updateLastInterfaceOrientation(value: Orientation) { self.eventManager.sendInterfaceOrientationDidChange(orientationValue: value.rawValue) lastInterfaceOrientation = value