2014-01-07 107 views
2

在我的Flex移动应用程序中,我的计算机上运行的AIR“adl”模拟器上的一切都很好。但是当我将应用程序部署到我的Android手机或平板电脑时,我遇到了这个奇怪的问题:Adob​​e AIR/Flex应用程序在纵向启动时显示空白屏幕

该应用程序在横向启动时工作正常,但是当我以纵向模式启动它时,它只显示空白的白色屏幕。如果将其旋转到横向模式,它会立即渲染,并且可以将其旋转回纵向模式,并且仍然可以工作。

我做了一些调试,看起来在纵向打开时,视图永远不会被添加到舞台上,甚至可以达到creationComplete。但是如果我旋转成风景,它会立即做到。

任何想法?

Main.mxml

<?xml version="1.0" encoding="utf-8"?> 
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          firstView="views.HomeView"> 

<fx:Metadata> 
    [ResourceBundle("resources")] 
</fx:Metadata> 

<!-- Global CSS styles --> 
<fx:Style source="styles/AppStyles.css" /> 

<fx:Script> 
    <![CDATA[ 
    // Initialize some vars... 
    ]]> 
</fx:Script> 

<fx:Declarations> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
</fx:Declarations> 

</s:ViewNavigatorApplication> 

查看/ HomeView.mxml

<?xml version="1.0" encoding="utf-8"?> 
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:components="components.*" 
    creationComplete="init()" menuKeyPressed="handleMenuKeyPressed(event)" 
    title="..."> 
<s:states> 
    <s:State name="portrait" /> 
    <s:State name="landscape" /> 
</s:states> 

<fx:Script source="ViewHandler.as" /> 
<fx:Script source="HomeViewHandler.as" /> 
<fx:Style source="../styles/HomeViewStyles.css" /> 

..... 
<s:Label id="resultsHeading" text="{s('Results')}" fontWeight="bold" addedToStage="setResultsHeadingFont()" /> 
    <s:HGroup width="100%" layoutDirection="{s('layoutDirection')}"> 
     <s:Group id="mainResultsGroup" width="90%"> 
      <s:layout.portrait> 
       <s:VerticalLayout /> 
      </s:layout.portrait> 
      <s:layout.landscape> 
       <s:HorizontalLayout gap="{getScaledNumber(100)}" /> 
      </s:layout.landscape> 
      <s:VGroup> 
..... 

这里init()不会被调用,直到应用程序为横向。

- 更新: 这里是我的application.xml:

<?xml version="1.0" encoding="utf-8"?> 
<application xmlns="http://ns.adobe.com/air/application/4.0"> 
    <id>com.myapp</id> 
    <versionNumber>0.1</versionNumber> 
    <supportedProfiles>mobileDevice</supportedProfiles> 
    <filename>MyApp</filename> 
    <name> 
    <text xml:lang="en">My App</text> 
    </name> 
    <android> 
    <manifestAdditions><![CDATA[<manifest android:installLocation="auto"> 
    <uses-sdk android:minSdkVersion="8" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch" /> 
</manifest>]]></manifestAdditions> 
    </android> 
    <iPhone> 
    <InfoAdditions><![CDATA[<key>UIStatusBarStyle</key> 
<string>UIStatusBarStyleBlackOpaque</string> 
<key>UIRequiresPersistentWiFi</key> 
<string>NO</string> 
<key>UIPrerenderedIcon</key> 
<true /> 
<key>UIApplicationExitsOnSuspend</key> 
<true /> 
<key>UIDeviceFamily</key> 
<array> 
    <!-- iPhone support --> 
    <string>1</string> 
    <!-- iPad support --> 
    <!--<string>2</string>--> 
</array>]]></InfoAdditions> 
    <requestedDisplayResolution>high</requestedDisplayResolution> 
    </iPhone> 
    <initialWindow> 
    <title>My App</title> 
    <content>MyApp.swf</content> 
    <visible>true</visible> 
    <fullScreen>false</fullScreen> 
    <autoOrients>true</autoOrients> 
    <!--<aspectRatio>landscape</aspectRatio>--> 
    <renderMode>cpu</renderMode> 
    <systemChrome>standard</systemChrome> 
    </initialWindow> 
    <icon> 
    <image48x48>icons/icon_48.png</image48x48> 
    <image57x57>icons/icon_57.png</image57x57> 
    <image72x72>icons/icon_72.png</image72x72> 
    <image96x96>icons/icon_96.png</image96x96> 
    <image114x114>icons/icon_114.png</image114x114> 
    <image144x144>icons/icon_144.png</image144x144> 
    <!--<image512x512>icons/icon_512.png</image512x512>--> 
    </icon> 
    <description> 
    <text xml:lang="en"> 
    </text> 
    </description> 
</application> 

顺便说一句,我使用的FlashDevelop。

+0

你可以发布你的'[Main] -app.xml'文件吗?我认为可能没有适当地设置“”或“”的值。 – Brian

+0

@Brian I更新并添加它。 – SZH

+0

你在用什么“景观”和“肖像”国家? –

回答

0

我终于搞定了,我无法解释这是如何或为什么会起作用。

我在HomeView.mxml底部的自定义组件:

<components:MyCustomComp id="customComp" right="0" left="0" bottom="0" 
         height="40%" maxHeight="700" /> 

当我height属性设置为一个数字,而不是百分比,一切工作正常。但我想要一个百分比,所以我忽略了MXML中的height属性,并且当我初始化视图时,我设置了customComp.percentHeight = 40;,并且它神奇地加载完美。

有时候真的Flex的困扰我...

FWIW,自定义组件是最后的视图,并从代码需要被删除并重新添加。在使用时,它覆盖视图中其余的组件。这是一个直接的观点,不在集团内部。也许这会帮助别人。

UPDATE

事实证明,上面并没有完全解决它。我最终还需要删除maxHeight属性。在AS3中设置maxHeight也没有解决它;我必须完全删除它。

0

在你的[项目] -app.xml文件时,请确保您有以下行:

<autoOrients>true</autoOrients> 

此值默认为false,所以你需要确保你已经设定,为您的应用程序在两个方向上正确启动。

+0

它设置为true。我更新了我的问题并添加了整个application.xml文件。 – SZH

相关问题