Xamarin.Plugin.DeviceOrientation icon indicating copy to clipboard operation
Xamarin.Plugin.DeviceOrientation copied to clipboard

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

Open fatfatson opened this issue 4 years ago • 1 comments

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

fatfatson avatar Jan 16 '20 14:01 fatfatson

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.

breyed avatar Dec 01 '20 17:12 breyed