Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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