2009-10-28 89 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)); 
    } 

這樣,當設備處於橫向模式只會自動旋轉(無論是景觀)