我的应用程序中有一个视图控制器,它希望始终以打印模式显示。此屏幕的对象是在运行时添加的,并且基于 protaint 模式。这是我的第一个视图控制器。
我尝试了一些代码,例如:
但他们都不能帮助我。可以知道这个状态的任何其他解决方案吗?
我在那里发现了一些东西:
但我不知道如何使用它。任何身体都可以帮忙吗?
我用这个代码
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// Return true for supported orientations
if (UserInterfaceIdiomIsPhone) {
return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown );
} else {
return true;
}
}
public override bool ShouldAutorotate ()
{
return true ;
}
public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation ()
{
return UIInterfaceOrientation.Portrait ;
}
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()
{
return UIInterfaceOrientationMask.Portrait ;
}
但它们都不起作用。
autoroatate 函数从不调用:(