Skip to content

Instantly share code, notes, and snippets.

@manishkungwani
Last active August 29, 2015 14:05
Show Gist options
  • Save manishkungwani/1a9f82afe3a8c3bcc2f7 to your computer and use it in GitHub Desktop.
Save manishkungwani/1a9f82afe3a8c3bcc2f7 to your computer and use it in GitHub Desktop.
Restrict ViewController to Portrait mode does not work!
public partial class PortraitOnlyViewController : UIViewController
{
public PortraitOnlyViewController () : base ("PortraitOnlyViewController", null)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
[Obsolete ("Deprecated in iOS6. Replace it with both GetSupportedInterfaceOrientations and PreferredInterfaceOrientationForPresentation")]
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// we're passed to orientation that it will rotate to. in our case, we could
// just return true, but this switch illustrates how you can test for the
// different cases
switch (toInterfaceOrientation)
{
case UIInterfaceOrientation.Portrait:
return true;
}
return false;
}
public override bool ShouldAutorotate ()
{
return false;
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()
{
return UIInterfaceOrientationMask.Portrait;
}
public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation ()
{
return UIInterfaceOrientation.Portrait;
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment