Copy link to clipboard
Copied
Working on Adove Air for IOS version.
Its auto oriented app.Means app should be rotated according to device orientation like showing portrait view ,if device is in portrait mode ,otherwise showing landscape mode.
I want to prevent app to rotating upside_down.
I try to prevent app in ORIENTATION_CHANGING event handler.
But its not work for IOS,only works for Android..
Can anyone tell me any alternative,I can use?
Thanks,
Amisha
Copy link to clipboard
Copied
I have a few landscape-only apps that I use a handler such as you are to prevent the default and/or set it. I don't know if you're working in Flash Pro timeline or a separate class file but if you're working in a class file, just add the protection modifiers (protected/public/etc):
import flash.events.StageOrientationEvent;
// this should be global either to Flash or a protected class var
var stageOrientation:String = stage.orientation;
// this is run during start-up init
if (startOrientation == StageOrientation.DEFAULT || startOrientation == StageOrientation.UPSIDE_DOWN)
{
stage.setOrientation(StageOrientation.ROTATED_RIGHT);
}
else
{
stage.setOrientation(startOrientation);
}
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeHandler);
// this is run any time orientation is changed to assure it's correct
function orientationChangeHandler(e:StageOrientationEvent):void
{
if (e.afterOrientation == StageOrientation.DEFAULT || e.afterOrientation == StageOrientation.UPSIDE_DOWN)
{
e.preventDefault();
}
}
On an iPad the default that I select in AIR becomes default and Apple will reject an app that cannot perform the upside down version of itself (since it's the same). So this just lets me check off to allow auto-orient, allows the user to spin either landscape side and simply prevents rotation if it's not my original selection.
The last time I compiled that app was AIR 17 and it is working fine. from OS 5 to OS 8
Copy link to clipboard
Copied
I want to keep app in both mode portrait as well as landscape
That means showing portrait view or landscape view according to device orientation
Its rotate in all direction like (default,rotated_left,rotated_right,upside_down)
Now I want to prevent app to rotating to upside_down.I don't want to allow app to rotate to upside_down
So I write following code,
stage.addEventListener( StageOrientationEvent.ORIENTATION_CHANGING, updateOrientation );
private function updateOrientation(e:StageOrientationEvent ):void
{
var startOrientation:String = e.afterOrientation ;
if (startOrientation == StageOrientation.UPSIDE_DOWN)
{
e.stopImmediatePropagation();
e.preventDefault();
}
}
App still rotating to upside_down.its not prevent from rotating
Thanks,
Amisha.
Copy link to clipboard
Copied
Is this going on the Apple store? As I mentioned above, I got rejected for not supporting upside down landscape.
Copy link to clipboard
Copied
Yes,Its going on the Apple Store.
I not want to allow app to Upside_down..
but in ios,preventDefault() is not working ..(its now prevent from rotating to upside_down)
Is there any option,how I can prevent app from rotating to upside_down?
Copy link to clipboard
Copied
You really need to read up and abide by their guidelines then.
iOS Human Interface Guidelines: Adaptivity and Layout
Be straightforward if your app runs in only one orientation. People expect to use your app in different orientations, and it’s best when you can fulfill that expectation. But if it’s essential that your app run in only one orientation, you should:
- Avoid displaying a UI element that tells people to rotate the device. Running in the supported orientation clearly tells people to rotate the device, if required, without adding unnecessary clutter to the UI.
- Support both variants of an orientation. For example, if an app runs only in landscape, people should be able to use it whether they’re holding the device with the Home button on the right or on the left. And if people rotate the device 180 degrees while using the app, it’s best if the app responds by rotating its content 180 degrees.
Apple really doesn't care why you think you need a specific orientation unless you have an amazing reason why, such as you absolutely require specific camera or button positions. At that point you can get rejected for poor UI design that breaks guidelines.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now