Skip to content

Instantly share code, notes, and snippets.

@julesx
Created June 1, 2017 19:56
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 julesx/125456417f98cd1dd9cc1b4124998514 to your computer and use it in GitHub Desktop.
Save julesx/125456417f98cd1dd9cc1b4124998514 to your computer and use it in GitHub Desktop.
[assembly: Xamarin.Forms.ExportRenderer(typeof(LandscapePage), typeof(LandscapePageRenderer))]
namespace Mobile.Core.Droid.Renderers
{
public class LandscapePageRenderer : PageRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
((FormsAppCompatActivity)Context).RequestedOrientation = ScreenOrientation.Landscape;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
((FormsAppCompatActivity)Context).RequestedOrientation = ScreenOrientation.Sensor;
}
}
}
[assembly: ExportRenderer(typeof(LandscapePage), typeof(LandscapePageRenderer))]
namespace Mobile.Core.iOS.Renderers
{
public class LandscapePageRenderer : PageRenderer
{
public override bool ShouldAutorotate()
{
return false;
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
return UIInterfaceOrientationMask.Landscape;
}
public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
{
return UIInterfaceOrientation.LandscapeLeft;
}
}
}
public class LandscapePage : ContentPage
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment