Open fatfatson opened 4 years ago
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.
lock for landscape first, then unlock, the screen remains landscape,even if the device is potrait.