Skip to content

Commit ac6d8e3

Browse files
douglowderkkafar
andauthored
fix(iOS): Respect all screen orientations on iPad (#3609)
## Description On iPad, SDK 55 router app would remain in landscape layout when the iPad was turned upside down. This was because `RNSScreen.mm` had the `UIInterfaceOrientationMaskAllButUpsideDown` set for allowed screen rotations. ## Changes Detect when running on iPad, and change the allowed screen orientations to `UIInterfaceOrientationMaskAll`. On non-iPad devices, behavior is unchanged. ## Test plan Tested on iPad simulator. --------- Co-authored-by: Kacper Kafara <kacperkafara@gmail.com>
1 parent 82ce103 commit ac6d8e3

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

guides/GUIDE_FOR_LIBRARY_AUTHORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ Allows for the customization of the type of animation to use when this screen re
180180

181181
Sets the current screen's available orientations and forces rotation if current orientation is not included. On iOS, if you have supported orientations set in `info.plist`, they will take precedence over this prop. Possible values:
182182

183-
- `default` - on iOS, it resolves to [UIInterfaceOrientationMaskAllButUpsideDown](https://developer.apple.com/documentation/uikit/uiinterfaceorientationmask/uiinterfaceorientationmaskallbutupsidedown?language=objc). On Android, this lets the system decide the best orientation.
183+
- `default` - on iOS, it resolves to [UIInterfaceOrientationMaskAllButUpsideDown](https://developer.apple.com/documentation/uikit/uiinterfaceorientationmask/uiinterfaceorientationmaskallbutupsidedown?language=objc), with
184+
exception for iPad devices, where it resolves to [UIInterfaceOrientationMaskAll](https://developer.apple.com/documentation/uikit/uiinterfaceorientationmask/all?language=objc). On Android, this lets the system decide the best orientation.
184185
- `all`
185186
- `portrait`
186187
- `portrait_up`

ios/RNSScreen.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,9 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations
20972097
if ([vc isKindOfClass:[RNSScreen class]]) {
20982098
return ((RNSScreen *)vc).screenView.screenOrientation;
20992099
}
2100+
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
2101+
return UIInterfaceOrientationMaskAll;
2102+
}
21002103
return UIInterfaceOrientationMaskAllButUpsideDown;
21012104
}
21022105

src/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export interface ScreenProps extends ViewProps {
378378
/**
379379
* In which orientation should the screen appear.
380380
* The following values are currently supported:
381-
* - "default" - resolves to "all" without "portrait_down" on iOS. On Android, this lets the system decide the best orientation.
381+
* - "default" - resolves to "all" without "portrait_down" on iPhone devices, "all" on iPad devices. On Android, this lets the system decide the best orientation.
382382
* - "all" – all orientations are permitted
383383
* - "portrait" – portrait orientations are permitted
384384
* - "portrait_up" – right-side portrait orientation is permitted

0 commit comments

Comments
 (0)