Skip to content

Commit

Permalink
[iOS] Fix orientation change in runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Jun 12, 2023
1 parent 54ab17e commit 974a7a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/classes/DisplayServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@
<param index="1" name="screen" type="int" default="-1" />
<description>
Sets the [param screen]'s [param orientation]. See also [method screen_get_orientation].
[b]Note:[/b] On iOS, this method has no effect if [member ProjectSettings.display/window/handheld/orientation] is not set to [constant SCREEN_SENSOR].
</description>
</method>
<method name="set_icon">
Expand Down
5 changes: 5 additions & 0 deletions platform/ios/display_server_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,11 @@

void DisplayServerIOS::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) {
screen_orientation = p_orientation;
if (@available(iOS 16.0, *)) {
[AppDelegate.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
} else {
[UIViewController attemptRotationToDeviceOrientation];
}
}

DisplayServer::ScreenOrientation DisplayServerIOS::screen_get_orientation(int p_screen) const {
Expand Down

0 comments on commit 974a7a8

Please sign in to comment.