【发布时间】:2013-04-14 17:16:51
【问题描述】:
我的应用中有一个视图控制器,它希望始终以打印模式显示。此屏幕的对象是在运行时添加的,并且基于 protaint 模式。这是我的第一个视图控制器。
我尝试了一些代码,例如:
但他们都无法帮助我。可以知道这个状态的任何其他解决方案吗?
我在那里发现了一些东西:
Monotouch - View created in landscape orientation is displayed in portrait orientation
但我不知道如何使用它。任何身体都可以帮忙吗?
我用这个代码
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 函数从不调用 :(
【问题讨论】:
-
所以你在不同的视图中有多个方向?在您的“支持的界面方向”中,您是否勾选了所有四个?并且只有在运行时启动的版本中,您才希望始终保持纵向,这是一个正确的假设吗?
-
是的,视图控制器是我的应用程序中的第一个视图控制器,我希望它是纵向的,并且在支持的界面方向中我有 3 个四边形
标签: ios iphone uiviewcontroller xamarin.ios rotation