C# Monotouch iPhone横向模式

C# Monotouch iPhone横向模式,c#,iphone,xamarin.ios,landscape,xib,C#,Iphone,Xamarin.ios,Landscape,Xib,从xib加载新的视图控制器时,如何使Monotouch iPhone应用程序保持横向模式 要在应用加载时切换到横向模式,请使用: app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight; 我希望能够在interface builder中旋转视图并设计界面。我可以点击interface builder视图角落中的旋转箭头进行旋转和保存,但它不会影响应用程序的运行 此链接表示要使用: viewRef.transform =

从xib加载新的视图控制器时,如何使Monotouch iPhone应用程序保持横向模式

要在应用加载时切换到横向模式,请使用:

 app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight;
我希望能够在interface builder中旋转视图并设计界面。我可以点击interface builder视图角落中的旋转箭头进行旋转和保存,但它不会影响应用程序的运行

此链接表示要使用:

viewRef.transform = CGAffineTransformMakeRotation(angle);
所以我试过了

 this.view.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);
但我得到了奇怪的结果。原来我用的是.view而不是.view。现在,它可以很好地用于:

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

使用这个不是更容易吗:

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
    {
        // Return true for supported orientations
        return ((toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown) && (toInterfaceOrientation != UIInterfaceOrientation.Portrait));
    }
这样,只有当设备处于横向模式(两种横向模式)时,它才会自动旋转