任何想法为什么我的代码不能在iPad 3 iOS 6上运行,或者它是Adobe air的错误?
以下代码适用于iPad和iPad 2及iOS5
if (startOrientation == StageOrientation.DEFAULT || startOrientation == StageOrientation.UPSIDE_DOWN){
stage.setOrientation(StageOrientation.ROTATED_RIGHT);}
else{
stage.setOrientation(startOrientation);
}
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener);
private function orientationChangeListener(e:StageOrientationEvent):void{
txt_rotate.text = 'Camed' + StageOrientation.ROTATED_LEFT;
if (e.afterOrientation == StageOrientation.DEFAULT || e.afterOrientation == StageOrientation.UPSIDE_DOWN){
e.preventDefault();
}else if(e.afterOrientation == StageOrientation.ROTATED_LEFT){
_stageOrientation = 'ROTATED_LEFT';
txt_rotate.text = _stageOrientation;
}else if(e.afterOrientation == StageOrientation.ROTATED_RIGHT){
_stageOrientation = 'ROTATED_RIGHT';
txt_rotate.text = _stageOrientation;
}
}
答案 0 :(得分:2)
Apple在iOS6 SDK中对方向回调进行了一些修改,因此不推荐使用某些功能。
preventDefault函数不能在StageOrientationEvent上运行。建议在需要时将Stage.autoOrients用于false。
http://blogs.adobe.com/airodynamics/2012/09/28/orientation-changes-in-air/