Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

ios: after unlock, orientation doesn't restore normal value. #24

Open
fatfatson opened this issue Jan 16, 2020 · 1 comment
Open

ios: after unlock, orientation doesn't restore normal value. #24

fatfatson opened this issue Jan 16, 2020 · 1 comment

Comments

@fatfatson
Copy link

lock for landscape first, then unlock,
the screen remains landscape,even if the device is potrait.

@breyed
Copy link

breyed commented Dec 1, 2020

To repro on iOS, add the following to a Xamarin.Forms page:

protected override void OnAppearing() {
	base.OnAppearing();
	CrossDeviceOrientation.Current.LockOrientation(DeviceOrientations.Landscape);
}

protected override void OnDisappearing() {
	base.OnDisappearing();
	CrossDeviceOrientation.Current.UnlockOrientation();
}

In AppDelegate.cs add:

[Export("application:supportedInterfaceOrientationsForWindow:")]
public UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, IntPtr forWindow) =>
	Plugin.DeviceOrientation.DeviceOrientationImplementation.SupportedInterfaceOrientations;

Wrap the page in a NavigationPage. Set the navigation page style like this:

Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.SetModalPresentationStyle(navigationPage.On<Xamarin.Forms.PlatformConfiguration.iOS>();

Push the navigation page with PushModalAsync.

At runtime, start in portrait. Cause the page to be pushed. The app orientation will change to landscape; however, keep the phone physically portrait. Cause the navigation page to pop. The orientation doesn't return to portrait.

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

No branches or pull requests

3 participants