【问题标题】:Phonegap change orientation at html page levelhtml页面级别的Phonegap更改方向
【发布时间】:2012-10-29 12:19:56
【问题描述】:

我有一个 phonegap 应用程序,我想显示一些纵向级别的页面和一些横向级别的页面。可能吗。顺便说一句,我禁用了方向更改并将其保持在 Android 清单中的纵向。 注意:如果我也可以在页面级别禁用方向更改会很酷。因为我只想旋转一页而所有其他页面都是静态的。

【问题讨论】:

    标签: android cordova user-interface screen-orientation


    【解决方案1】:

    您必须为此编写一些本机编码。

    Phonegap 提供的OrientationHelper 类包含一个事件page_OrientationChanged

    您可以在该事件中检查该页面。

    举例

    void page_OrientationChange(object sender, CancelEventArgs e)
    {
      if(CordovaBrowser.Source.ToString().Contains("pagename"))
       {
          int i = 0;
    
                switch (e.Orientation)
                {
                    case PageOrientation.Portrait: // intentional fall through
                    case PageOrientation.PortraitUp:
                        i = 0;
                        break;
                    case PageOrientation.PortraitDown:
                        i = 180;
                        break;
                    case PageOrientation.Landscape: // intentional fall through
                    case PageOrientation.LandscapeLeft:
                        i = -90;
                        break;
                    case PageOrientation.LandscapeRight:
                        i = 90;
                        break;
                }
       }
    }
    

    这应该可以工作

    【讨论】:

      猜你喜欢
      • 2011-10-05
      • 2020-09-03
      • 1970-01-01
      • 1970-01-01
      • 2019-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多