我正在开发一个带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