Created
June 1, 2016 20:38
-
-
Save rasmuschristensen/5cfee152366eb19adac599a606b857e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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