0

How do I keep a Monotouch iPhone app in landscape mode when loading a new view controller from an xib?

To switch to landscape mode when the app loads I use:

 app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight;

I would like to be able to rotate the view in interface builder and design the interface. I can hit the rotation arrow in the corner of my interface builder view to rotate it and save, but it does not affect the app when it is run.

Bryan
  • 17,201
  • 24
  • 97
  • 123

2 Answers2

1

Isn't it even more easy just to use this:

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
    {
        // Return true for supported orientations
        return ((toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown) && (toInterfaceOrientation != UIInterfaceOrientation.Portrait));
    }

This way it will only autorotate when the device is in landscape mode (both the landscapes)

Kevinc
  • 166
  • 10
0

This link Monotouch rotate view in Portrait/Landscape say to use:

viewRef.transform = CGAffineTransformMakeRotation(angle);

So I tried

 this.view.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);

But I got strange results. It turned out I was using .view instead of .View. Now it works great with:

 this.View.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);
Community
  • 1
  • 1
Bryan
  • 17,201
  • 24
  • 97
  • 123