Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly lock orientation #2221

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions ios/RNSScreenWindowTraits.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,17 @@ + (void)enforceDesiredDeviceOrientation
UIInterfaceOrientation currentInterfaceOrientation = [RNSScreenWindowTraits interfaceOrientation];
UIInterfaceOrientation newOrientation = UIInterfaceOrientationUnknown;
if ([RNSScreenWindowTraits maskFromOrientation:currentDeviceOrientation] & orientationMask) {
if (!([RNSScreenWindowTraits maskFromOrientation:currentInterfaceOrientation] & orientationMask)) {
// if the device orientation is in the mask, but interface orientation is not, we rotate to device's orientation
newOrientation = currentDeviceOrientation;
} else {
if (currentDeviceOrientation != currentInterfaceOrientation) {
// if both device orientation and interface orientation are in the mask, but in different orientations, we
// rotate to device's orientation
newOrientation = currentDeviceOrientation;
}
}
// force orientation to device orientation
newOrientation = currentDeviceOrientation;
} else {
if (!([RNSScreenWindowTraits maskFromOrientation:currentInterfaceOrientation] & orientationMask)) {
// if both device orientation and interface orientation are not in the mask, we rotate to closest available
// rotation from mask
newOrientation = [RNSScreenWindowTraits defaultOrientationForOrientationMask:orientationMask];
} else {
// if the device orientation is not in the mask, but interface orientation is in the mask, do nothing
// if the device orientation is not in the mask, but interface orientation is in the mask, rotate to interface
// orientation
newOrientation = currentInterfaceOrientation;
}
}
if (newOrientation != UIInterfaceOrientationUnknown) {
Expand Down
Loading