限制每个视图控制器的方向

时间:2015-09-21 09:03:00

标签: ios uiviewcontroller xamarin xamarin.ios orientation

我想在每个视图控制器中说出他支持哪种方向并将其限制为它们。这就是我试过的:

这些解决方案似乎都不起作用。或者我会错过重要的事情吗?如何限制视图控制器A仅为横向的方向,视图控制器B仅为纵向,视图控制器C可以所有可用方向显示?

1 个答案:

答案 0 :(得分:1)

在视图控制器中覆盖GetSupportedInterfaceOrientations()应该可以解决问题:

public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()     {
  return UIInterfaceOrientationMask.LandscapeRight;
}

您在此处返回的方向将与应用程序允许的方向(项目属性)或您在应用程序委托中允许的方向相交。因此,请务必在那里指定所有方向或您想要支持的最大集合

请参阅此处查看documentation

相关问题