1
我正在開發一個ipad應用程序,因爲我將應用程序縱橫比設置爲橫向並自動指向應用程序描述符xml中的true,如下所示:如何在加載啓動畫面時停止Ipad屏幕方向? - 在Flex移動應用程序
<!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape"). Optional. Mobile only. Default is the natural orientation of the device -->
<aspectRatio>portrait</aspectRatio>
<autoOrients>false</autoOrients>
默認情況下,我的應用程序在橫向視圖中加載,但是當用戶在「Landscape_Left」視圖中持有ipad時,即面向用戶的左手側的ipad-home-button,則啓動屏幕旋轉至「Landscape_right」上下翻轉。然後,用戶必須旋轉iPad 180度才能以直觀的視角查看應用,每次打開應用時都會發生這種情況。我無法阻止應用程序旋轉到默認的橫向視圖,我試圖在預初始化時將方向設置爲ROTATED_LEFT,但其旋轉到默認然後是左。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160"
addedToStage="application1_addedToStageHandler(event)"
preinitialize="application1_preinitializeHandler(event)"
creationComplete="application1_creationCompleteHandler(event)"
backgroundColor="#333A42"
splashScreenImage="@Embed('assets/app_logo.png')"
splashScreenMinimumDisplayTime="3000" >
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.managers.ISystemManager;
protected function application1_addedToStageHandler(event:Event):void
{
// TODO Auto-generated method stub
trace("Orientation ::"+this.stage.orientation);
}
protected function application1_preinitializeHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
trace("Aspect Ratio ::"+this.aspectRatio);
var calAR:String = this.width > this.height ? StageAspectRatio.LANDSCAPE : StageAspectRatio.PORTRAIT;
trace("Calculate Aspect Ratio ::"+calAR);
var sm:ISystemManager = systemManager;
if (sm && sm.stage && sm.isTopLevelRoot())
{
// sm.stage.addEventListener("orientationChanging", stage_orientationChangingHandler);
// sm.stage.addEventListener("orientationChange", stage_orientationChange);
trace("System manager Orientation ::"+sm.stage.orientation);
trace("System manager Device Orientation ::"+sm.stage.deviceOrientation);
sm.stage.setOrientation(StageOrientation.ROTATED_LEFT);
sm.stage.setAspectRatio(StageAspectRatio.LANDSCAPE);
}
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var sm:ISystemManager = systemManager;
if (sm && sm.stage && sm.isTopLevelRoot())
{
trace("System manager Orientation ::"+sm.stage.orientation);
trace("System manager Device Orientation ::"+sm.stage.deviceOrientation);
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:BorderContainer height="300" horizontalCenter="0" verticalCenter="0">
<s:VGroup horizontalAlign="center">
<s:TextInput id="txtAspectRatio"/>
<s:Button label="Test" click="{txtAspectRatio.text = this.stage.orientation}"/>
</s:VGroup>
</s:BorderContainer>
</s:Application>
有沒有解決這個問題?它甚至在調用Application構造函數之前旋轉。