2009-10-28 88 views
0

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

app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight; 

我希望能够在旋转界面生成器视图和设计接口:

要在应用程序加载我用切换到横向模式。我可以在界面生成器视图的角落点击旋转箭头来旋转它并保存,但它不会影响运行时的应用程序。

回答

0

此链接Monotouch rotate view in Portrait/Landscape说使用:

viewRef.transform = CGAffineTransformMakeRotation(angle); 

所以,我想

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

但是我得到了奇怪的结果。原来我使用的是.view而不是.View。现在,它的伟大工程具有:

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

是不是应该更简单,你只使用这个:

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

这样,当设备处于横向模式只会自动旋转(无论是景观)