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

Add support for locking screen orientation on iOS #6461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frenzibyte
Copy link
Member

To be used in osu! for locking orientation during gameplay.

InvokeOnMainThread(() =>
{
if (OperatingSystem.IsIOSVersionAtLeast(16))
((IOSWindow)host.Window).UIWindow.RootViewController!.SetNeedsUpdateOfSupportedInterfaceOrientations();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ugly line will be improved somewhat once the window API in 753ab06 gets in. Should've been in a separate PR but alas.

if (OperatingSystem.IsIOSVersionAtLeast(16))
((IOSWindow)host.Window).UIWindow.RootViewController!.SetNeedsUpdateOfSupportedInterfaceOrientations();
else
UIViewController.AttemptRotationToDeviceOrientation();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to assume this is the only function to call as the old counterpart of setNeedsUpdateOfSupportedInterfaceOrientations for iOS -16, I don't have an old iOS device to test this with but documentation and few stackoverflow threads show that this should do the job:

CleanShot 2024-12-16 at 06 46 59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant