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

Unable to Programatically Set Fixed Orientation for a ViewController

$
0
0

I am writing an iOS application in which one of the ViewControllers shows a bar chart which I want to display in a Landscape orientation at all times. The rest of the application supports both portrait and landscape rotations. It's just the graph controller which needs to be fixed to a landscape orientation.

I have overridden the necessary methods, but I still see the graph in Portrait orientation when I run it in the iOS simulator, and it rotates when I simulate hardware rotation as well.

public override bool ShouldAutorotate()
{
  return false;
}

[Obsolete]
public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
{
  return InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft;
}

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

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

I don't understand why the view displays in portrait orientation even though I overrode the methods which handle the supported orientations.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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