diff --git a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist
index ee5f1d35aeb..3d2ae6b52b9 100644
--- a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist
+++ b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist
@@ -54,7 +54,7 @@
UISupportedInterfaceOrientations~ipad
- $interface_orientations
+ $ipad_interface_orientations
$additional_plist_content
$plist_launch_screen_name
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp
index 6a452f08fa0..769d97694a9 100644
--- a/platform/ios/export/export_plugin.cpp
+++ b/platform/ios/export/export_plugin.cpp
@@ -541,6 +541,44 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_
}
strnew += lines[i].replace("$interface_orientations", orientations);
+ } else if (lines[i].contains("$ipad_interface_orientations")) {
+ String orientations;
+ const DisplayServer::ScreenOrientation screen_orientation =
+ DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")));
+
+ switch (screen_orientation) {
+ case DisplayServer::SCREEN_LANDSCAPE:
+ orientations += "UIInterfaceOrientationLandscapeRight\n";
+ break;
+ case DisplayServer::SCREEN_PORTRAIT:
+ orientations += "UIInterfaceOrientationPortrait\n";
+ break;
+ case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
+ orientations += "UIInterfaceOrientationLandscapeLeft\n";
+ break;
+ case DisplayServer::SCREEN_REVERSE_PORTRAIT:
+ orientations += "UIInterfaceOrientationPortraitUpsideDown\n";
+ break;
+ case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
+ // Allow both landscape orientations depending on sensor direction.
+ orientations += "UIInterfaceOrientationLandscapeLeft\n";
+ orientations += "UIInterfaceOrientationLandscapeRight\n";
+ break;
+ case DisplayServer::SCREEN_SENSOR_PORTRAIT:
+ // Allow both portrait orientations depending on sensor direction.
+ orientations += "UIInterfaceOrientationPortrait\n";
+ orientations += "UIInterfaceOrientationPortraitUpsideDown\n";
+ break;
+ case DisplayServer::SCREEN_SENSOR:
+ // Allow all screen orientations depending on sensor direction.
+ orientations += "UIInterfaceOrientationLandscapeLeft\n";
+ orientations += "UIInterfaceOrientationLandscapeRight\n";
+ orientations += "UIInterfaceOrientationPortrait\n";
+ orientations += "UIInterfaceOrientationPortraitUpsideDown\n";
+ break;
+ }
+
+ strnew += lines[i].replace("$ipad_interface_orientations", orientations);
} else if (lines[i].contains("$camera_usage_description")) {
String description = p_preset->get("privacy/camera_usage_description");
strnew += lines[i].replace("$camera_usage_description", description) + "\n";
diff --git a/platform/ios/view_controller.mm b/platform/ios/view_controller.mm
index 6f6c04c2c83..787e767109d 100644
--- a/platform/ios/view_controller.mm
+++ b/platform/ios/view_controller.mm
@@ -258,7 +258,11 @@
case DisplayServer::SCREEN_PORTRAIT:
return UIInterfaceOrientationMaskPortrait;
case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
- return UIInterfaceOrientationMaskLandscapeRight;
+ if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+ return UIInterfaceOrientationMaskLandscapeLeft;
+ } else {
+ return UIInterfaceOrientationMaskLandscapeRight;
+ }
case DisplayServer::SCREEN_REVERSE_PORTRAIT:
return UIInterfaceOrientationMaskPortraitUpsideDown;
case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
@@ -268,7 +272,11 @@
case DisplayServer::SCREEN_SENSOR:
return UIInterfaceOrientationMaskAll;
case DisplayServer::SCREEN_LANDSCAPE:
- return UIInterfaceOrientationMaskLandscapeLeft;
+ if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
+ return UIInterfaceOrientationMaskLandscapeRight;
+ } else {
+ return UIInterfaceOrientationMaskLandscapeLeft;
+ }
}
}