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.