Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasmuschristensen/5cfee152366eb19adac599a606b857e6 to your computer and use it in GitHub Desktop.
Save rasmuschristensen/5cfee152366eb19adac599a606b857e6 to your computer and use it in GitHub Desktop.
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, UIWindow forWindow)
{
if (Xamarin.Forms.Application.Current == null || Xamarin.Forms.Application.Current.MainPage == null)
{
return UIInterfaceOrientationMask.Portrait;
}
var navigationPage = Xamarin.Forms.Application.Current.MainPage as NavigationPage;
var orientationPage = navigationPage.CurrentPage as ISupportOrientation;
if (orientationPage != null)
{
UIInterfaceOrientationMask supportedMask = new UIInterfaceOrientationMask();
foreach (var orientation in orientationPage.SupportedOrientation)
{
switch (orientation)
{
case DeviceOrientations.Portrait:
supportedMask |= UIInterfaceOrientationMask.Portrait;
break;
case DeviceOrientations.Landscape:
supportedMask |= UIInterfaceOrientationMask.Landscape;
break;
default:
break;
}
}
return supportedMask;
}
return UIInterfaceOrientationMask.Portrait;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment