我用這個代碼,迫使我的主屏幕(我的應用程序的第一個畫面)是人像,而其他屏幕依然支持所有方向:力的ios應用程序的第一個屏幕變爲縱向,但其他屏幕景觀的iOS 6+
public class RltNavigationController : UINavigationController
{
public RltNavigationController() : base()
{
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
if(this.TopViewController is HomeScreen)
return UIInterfaceOrientationMask.Portrait ;
else
return UIInterfaceOrientationMask.AllButUpsideDown ;
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// Return true for supported orientations
if(this.TopViewController is HomeScreen)
return (toInterfaceOrientation == UIInterfaceOrientation.Portrait);
else
return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown) ;
}
}
現在,假設該設備上的主屏幕上橫向(儀表lanscape但屏幕只顯示畫像)。現在,如果用戶轉到其他視圖,其他視圖現在將顯示縱向,同時它應顯示橫向。我可以選擇什麼解決方案來加載其實際旋轉的第二個視圖?
編輯
感謝所有的答案,只是通知已經問題不是我不能強迫屏幕變爲縱向。爲了瞭解這個問題,請按照場景:
- >首先屏強制變爲縱向。
- >設備是景觀權利,我在主屏幕(使主屏幕顯示人像)
- >現在我切換到支持所有方向
另一個屏幕 - >在另一個屏幕,因爲父屏幕的畫像拿給畫像(而由於設備山水它應該顯示景觀)
謝謝, 你能給我一個上述解決方案的例子或教程? –