【问题标题】:Orientation Portrait and PortraitUpSideDown Only For One Window方向 Portrait 和 PortraitUpSideDown 仅适用于一个窗口
【发布时间】:2014-03-19 08:58:18
【问题描述】:

我有 10 个窗口。

初始窗口是 loginWindow 我想为 Portrait 和 PortraitUpSideDown 设置方向。 其余窗口将具有横向和纵向。

在 Tiapp.xml 中

        <key>UISupportedInterfaceOrientations~iphone</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>

为我的应用程序设置所有方向,启用纵向、上下颠倒、横向和横向。

我只需要那些用于 LoginWindow 的 Portrait 和 PortraitUpSideDown。
窗口的其余部分确实具有所有方向,即纵向、上下颠倒、横向和横向。

谁能建议我如何才能为我的应用程序获得这种行为。

【问题讨论】:

    标签: javascript ios titanium orientation titanium-alloy


    【解决方案1】:

    您需要使用不同的窗口并为每个窗口定义您希望允许的方向。

    我的意思是,你必须像这样创建 loginWindow:

    var loginWindow = Ti.UI.createWindow({
        orientationModes : [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT],
        fullscreen : false,
        navBarHidden : true
    
    });
    winPortrait.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT];
    

    您要允许所有方向的窗口必须像这样创建:

    var appWindow = Titanium.UI.createWindow({
    
        width : Ti.UI.FILL,
        height : Ti.UI.FILL,
        fullscreen : false,
        navBarHidden : true,
        orientationModes : [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT, Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT]
    });
    appWindow.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT, Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT];
    

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      将您的 loginWindow 显示为模态视图,然后将此方法设置为所需的方向。

      - (BOOL) shouldAutorotate
      {            
          return NO;
      }
      
       - (NSUInteger) supportedInterfaceOrientations
      {
          return UIInterfaceOrientationMaskPortrait;
      }
      

      【讨论】:

        【解决方案3】:

        不建议在 iOS 中为单个应用使用不同的方向模式。请阅读Orientation design principles

        Apple's Developer documentation 说:“人们希望使用你的 应用程序在不同的方向,最好是当你能做到这一点 期望。”换句话说,不要将处理方向视为一种 麻烦不过是一个机会。

        Apple 进一步建议在选择锁定或支持时 方向,您应该考虑遵循以下原则:

        在 iPhone/iPod Touch 上 - 不要在单个应用程序中混合窗口方向;因此,要么锁定整个应用的方向,要么对方向变化做出反应。

        在 iPhone 上 - 不支持纵向倒置方向,因为这可能会使用户在接听电话时将手机倒置。

        但是,您可以使用 orientationMode property of window 实现特定窗口的方向

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-02-07
          • 1970-01-01
          • 1970-01-01
          • 2016-04-08
          • 1970-01-01
          • 1970-01-01
          • 2013-08-26
          • 1970-01-01
          相关资源
          最近更新 更多