在Xamarin.iOS中未调用ShouldAutorotate和GetSupportedInterfaceOrientations

时间:2014-06-14 01:14:41

标签: uiviewcontroller xamarin.ios rotation xamarin

我制作了像

这样的UIViewController
public class MyViewController : UIViewController
{
    ...

    public override bool ShouldAutorotate ()
    {
        return true;
    }

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

并在AppDelegate.cs中使用它。

Window.RootViewController = new MyViewController();

当我运行此代码时," ShouldAutorotate"和" GetSupportedInterfaceOrientations"在视图初始化阶段被多次调用,但是在显示应用程序视图后,它们再也没有调用过。

我检查了Info.plist中的方向设置是否有效。 iOS SDK Target为7.1,Xamarin Studio Version为5.0.1(build 3),Xamarin.iOS Version为7.2.3.39。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

iOS会在视图加载时检查这些视图并缓存在显示期间使用的答案。