Nik*_*ane 1 rotation xamarin.ios auto-rotation
需要防止特定视图控制器上的屏幕旋转
我在下面尝试过 -
public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
{
return false;
}
public override bool ShouldAutorotate()
{
return false;
}
public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
{
return UIInterfaceOrientation.Portrait;
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
{
return UIInterfaceOrientationMask.Portrait;
}
Run Code Online (Sandbox Code Playgroud)
没有任何效果.
提前致谢!
您可以通过此解释解决此问题.
1)在你AppDelegate中添加一个布尔值作为例子
public bool disableAllOrientation = false;
Run Code Online (Sandbox Code Playgroud)
2)修改AppDelegate中的UIInterfaceOrientationnMask
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, UIWindow forWindow)
{
if (disableAllOrientation == true)
{
return UIInterfaceOrientationMask.Portrait;
}
return UIInterfaceOrientationMask.All;
}
Run Code Online (Sandbox Code Playgroud)
3)在视图的控制器中调用您想要更改方向
appDelegate.disableAllOrientation = true;
Run Code Online (Sandbox Code Playgroud)
4)当视图关闭或更改时,您需要再次将布尔值放在false中,并且只在您需要时将屏幕置于原始方向.
appDelegate.disableAllOrientation = false;
Run Code Online (Sandbox Code Playgroud)
我希望这能解决你的问题我几天前遇到同样的问题,这对我很有帮助.
归档时间: |
|
查看次数: |
2001 次 |
最近记录: |