我正在開發一個帶Xamarin MVVMCross技術的應用程序,並且想問一個關於InterfaceOrientation選項的問題:應用程序的所有視圖控制器都支持所有方向,但應該只使用縱向模式。 當我去從他人肖像模式視圖控制器,我能夠保持在縱向模式下本人的肖像視圖 - 控制由於方法在我AppDelegate.cs:以編程方式將方向從橫向改爲縱向模式xamarin IOS
[Export("application:supportedInterfaceOrientationsForWindow:")]
public UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, IntPtr forWindow)
{
if (this.RestrictRotation)
return UIInterfaceOrientationMask.All;
else
return UIInterfaceOrientationMask.Portrait;
}
但是,當我去我的portraitview控制器時,裝置在LandscapeLeft(LandscapeRight)方向中,不調用AppDelegate.cs方法中的GetSupportedInterfaceOrientations,並且該視圖控制器在Landscape模式下打開。 有沒有辦法在Xamarin IOS中以編程方式將方向從橫向更改爲縱向模式?
如果要控制單個視圖控制器的方向不使用AppDelegate
GetSupportedInterfaceOrientations
方法,而不是用你想控制的一個在的ViewController謝謝
感謝Singhal2,它就是我一直在尋找! – Andrei