Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Can't prevent screen rotation

$
0
0

Okay, I feel like an idiot because I've done this before but I've been stuck now for a couple of days.

In my app I do want to allow rotation in many (most) cases. So in my Info.plist file I have 3 of the 4 device orientations selected (which I think is the default when creating a new project). On a couple of screens I want to keep the app in Portrait mode. In a plain vanilla UIViewController class I went ahead and added:

public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
  return UIInterfaceOrientationMask.Portrait;
}

public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
{
  return UIInterfaceOrientation.Portrait;
}

and for good measure

public override bool ShouldAutorotate()
{
  return false;
}

Yet the damn thing still rotates! What gives? Am I missing something obvious?

JB


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>