代码之家  ›  专栏  ›  技术社区  ›  Bryan

单触式iPhone横向模式

  •  0
  • Bryan  · 技术社区  · 15 年前

    从XIB加载新的视图控制器时,如何保持MonoTouch iPhone应用程序处于横向模式?

    要在加载应用程序时切换到横向模式,我使用:

     app.StatusBarOrientation = UIInterfaceOrientation.LandscapeRight;
    

    我希望能够在界面生成器中旋转视图并设计界面。我可以点击界面构建器视图角上的旋转箭头来旋转和保存它,但是它不会影响应用程序的运行。

    2 回复  |  直到 13 年前
        1
  •  1
  •   Kevinc    13 年前

    仅仅使用这个不是更容易吗?

    public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
        {
            // Return true for supported orientations
            return ((toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown) && (toInterfaceOrientation != UIInterfaceOrientation.Portrait));
        }
    

    这样,只有当设备处于横向模式(两种横向模式)时,它才会自动旋转。

        2
  •  0
  •   Community CDub    8 年前

    这个链接 Monotouch rotate view in Portrait/Landscape 使用说明:

    viewRef.transform = CGAffineTransformMakeRotation(angle);
    

    所以我尝试

     this.view.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);
    

    但我得到了奇怪的结果。原来我用的是.view而不是.view。现在它非常适合:

     this.View.Transform =  CGAffineTransformMakeRotation(3.141f * 0.5f);