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

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

 app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight;

我希望能够在界面构建器中旋转视图并设计界面。我可以点击界面构建器视图角落的旋转箭头来旋转它并保存,但它在运行时不会影响应用程序。

有帮助吗?

解决方案 2

此链接纵向/横向的Monotouch旋转视图说使用:

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));
    }

这样它只会在设备处于横向模式(两个风景)时自动旋转

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top