Programmatic device orientation changes

Is there a simple way to programmatically rotate the device's orientation?
I'd like to be able to transition from a landscape view to a portrait view upon pushing a new (portrait-only) viewcontroller to a navigationcontroller.
I have written some logic to manually set the orientation to portrait mode, which involves setting the transform of the root viewcontroller, setting the frame, changing the status bar location, etc. I then set a flag that tells me that the orientation is manually set to portrait mode.
shouldAutorotateToInterfaceOrientation will always return true, and my "willRotate/didRotate" methods will do nothing if the flag is set and the physical/actual orientation is portrait.
The problem I am facing is that after this programmatic rotation, if the user physically rotates the device to portrait, the screen will briefly 'glitch' as if it were trying to animate a rotation from portrait back to portrait, and doesn't know that it doesn't have to do anything. I know that this animation is not due to my own logic because my "willRotate/didRotate" methods skipped the usual animation logic that I put there.
So, maybe there's a better way to do this, or there's a way to cover the glitch. Does anyone know how? I'll try to post sample code asap.
- Jae

yes you can force a programatc change to what ever orientation you like by adding the following code to the viewillAppear etc method of the parent or child view of the transition
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
Of course this is an example of forcing Portrait. The other UIInterfaceOrientation parameter values work as well for other orientations. You get a compiler warning about UIDevice may not recognize the call but it does, at least for now. Not sure why the warning. Perhaps this method will be removed in the future. For now it works.

Similar Messages

  • Web page auto-zooms on orientation change in iOS 7

    I had a web page that worked perfectly well until Apple came out with iOS 7 today and it broke the layout when screen orientation is changed.
    Basically, when I have focus on a text area and rotate the screen to landscape view, the entire page zooms in. If focus is taken out of the text area and turned back to Portrait, things are back normal.
    Rotation also works well when the text areas does not have focus.
    I already have the following meta-tag in place (to ensure we block zooming):
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0;;">
    Any ideas what's causing this awkward behavior?
    Questions also on StackOverflow @ http://stackoverflow.com/questions/18896083/auto-zoom-on-orientation-change-in-i os-7.

    This is a problem many and probably all are having with iOS7 "Multitasking."
    Here is probably the largest and most helpful thread about it, but it doesn't fix anything: https://discussions.apple.com/message/24582055#24582055

  • [iPhone] How to get current device orientation...

    Again, Should be simple, but I am having trouble finding a way to poll the device to get it's current orientation. That is, where the status bar would be drawn if there is one. I see notifications for changes, etc.. but sometimes I want to check the orientation of the device NOW.
    thanks in advance for the pointers.
    michael golden

    Search bar in Docs is sad
    Getting the Current Device Orientation
    orientation property
    generatesDeviceOrientationNotifications property
    – beginGeneratingDeviceOrientationNotifications
    – endGeneratingDeviceOrientationNotifications

  • HTML Article put together dynamically, scroll only possible after orientation change

    Hi guys,
    i have encountered the following problem today:
    im having a HTML page put together dynamically from a JSON source file, handling the JSON information with jQuery. i am uploading said HTML page (html page is empty until the page is in the DPS stack, then it builds itself) as an HTML article with "Smooth Scrolling: Vertical". So far, so good.
    When i open the page inside the Adobe Viewer App on my iPad, i can see the "first" part of the page (the first 1024px in portrait-orientation) but i am not able to scroll further down the page.
    however, when i do a orientation change of the device (turn it landscape and then back), i can scroll perfectly fine and am able to see everything on the page (so im quite sure the conversion from json to jquery to html does work). even stranger, when i let the page tell me its height ( via $("body").height() and $(document).height() ) it shows me, that the height of the page is indeed (e.g.) 10.000px, but i am not able to scroll down until i do the orientation change.
    am i missing something? im pretty sure that my code is correct, because once i change the orientation of my device, everything does work flawless.
    i hope my problem is understandable, any help is much appreciated.
    thanks
    Max

    Nevermind... since the HTML is empty, when the magazin gets opened, i suspect the HTML tells DPS "hey, my height is 0px, dont bother scrolling!". but once i am on the page itself and the process of bulding the page starts (HTML elements are added on the fly), it doesnt tell DPS "hey, my height changed, check if i need to be scrollable please" since im not able to scroll. when im changing orientation, it forces DPS to rerender the page and thus getting the correct height of the page.
    my workaround: setting the body height to (e.g.) 20.000px and then, later on, reduce it to the actual height needed by the HTML elements.
    but still: can someone explain me the process of loading / rendering pages inside DPS? when do DPS render pages, does it render pages the first time i open the app and then again when im on the page itself (or rather a page before the actual page?) is there a command to force DPS to rerender the page?

  • Air for Android video object displays on orientation change

    I have an Android app that plays a video using the normal video object, ie:
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    stream = new NetStream(nc);
    stream.client = this ;
    stream.addEventListener(NetStatusEvent.NET_STATUS, statusHandlerx);
    softwareVideo = new Video(640, 480);
    softwareVideo.x = 0;
    softwareVideo.y = 0;
    addChild(softwareVideo);
    When the video is playing if there is an orientation change, before the screen adjusts,  you can see a full screen version of the video behind the 640x480 in the area of the screen that adjusted yet.  So if the video is in portrait and the orientation is switched to landscape, in the right befow the stage adjusts to landcape you can see the right part of a fullscreen version of the video.
    Also when I remove the video object you can still see the last frame of the video in that area.
    HELP.  Is this a bug?

    Hi,
    Please log a bug at bugbase.adobe.com with a sample app(sources,swf,app-xml and assets) with which bug can be reproduced at our end. Also please mention the devices with OS version and the AIR build version on which bug is reproducible. A video demonstarting the bug would be really helpful for us.
    Also please mention the bug number here on forum so that we can look into this issue.
    -Nimisha

  • Iphone device orientation

    Hi,
    I am facing strange problem with UIDevice setOrientation method and I will really appreciate if someone could solve this problem.
    I am navigating between two view controllers thru push and pop. Screen A is list of image series and Screen B display images in scrollview of that series. For a particular series I want to show images in landscape mode so I use
    Code:
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft];
    in viewDidAppear method of Screen B.
    This works fine and Interface is rotated to landscape. Please note device is still held as portrait.
    Now if I go back to screen A by "POP", Screen A is displayed as landscape orientation, device is still in portrait. Although shouldAutorotateToInterfaceOrientation method return true on A screen then why it is not rotating to portrait, since device is held as portrait.
    shouldAutorotateToInterfaceOrientation on screen B restrict the interface orientation to landscape.
    I have spent more than two days now to solve this out but couldn't find a solution. plz help.
    Thanks in advance.

    I'm not sure what you may be doing wrong. In my apps, I generally lock down one orientation, but after seeing your post when I next looked at the UIViewController Class Reference which you can reach by right-click or control-click on any UIVuewController class or method name in your code and select find in API reference,
    I found this:{quote}Handling View Rotations
    By default, the UIViewController class displays views in portrait mode only. To support additional orientations, you must override the shouldAutorotateToInterfaceOrientation: method and return YES for any orientations your subclass supports. If the autoresizing properties of your views are configured correctly, that may be all you have to do. However, the UIViewController class provides additional hooks for you to implement additional behaviors as needed.
    To temporarily turn off features that are not needed or might otherwise cause problems during the orientation change, you can override the willRotateToInterfaceOrientation:duration: method and perform the needed actions there. You can then override the didRotateFromInterfaceOrientation: method and use it to reenable those features once the orientation change is complete.
    If you want to perform custom animations during an orientation change, you can do so in one of two ways. Orientation changes used to occur in two steps, with notifications occurring at the beginning, middle, and end points of the rotation. However, in iPhone OS 3.0, support was added for performing orientation changes in one step. Using a one-step orientation change tends to be faster than the older two-step process and is generally recommended for any new code.
    To add animations for a one-step orientation change, override the willAnimateRotationToInterfaceOrientation:duration: method and perform your animations there. To use the older two-step method, override one or both of the willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: and willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: methods to configure your animations before each step. You must choose only one technique and override just the methods associated with that technique. If you override either method associated with the two-step technique, the view controller uses that technique by default.
    {quote}
    My take on that is that you may need to play around with overriding willRotateToInterfaceOrientation:duration and didRotateFromInterfaceOrientation.
    These and some of the other available methods are not in the standard templates and you have to add them yourself. I'd say take a good look at the docs again and see if it explains the behavior you are seeing and then make your changes one at a time and see what changes.
    I've learned the hard way that making a bunch of changes to something that worked and finding which thing broke some behavior is really hard unless you know exactly what set of changes will affect a specific behavior.
    Let us know if this helps.

  • Handling Device Orientation in iAd Producer

    Hi,
    I'm almost on the final stage of my iAd project and I'm using the iAd Producer. The only thing left is handling device orientation. When I change the view of my project from Portrait to Landscape, some objects gets cutoff. My question is how to properly handle the orientation. I thought of creating a new page with the view set to Landscapre (while the other is Portrait) but I am not sure if that's the right way (i haven't tested it yet).
    Or is there any JS code that needs to be done? I appreciate guiding me on that part if that is so.
    Thanks in advance!
    Mark

    Feel free vary the orientation on a page-by-page basis however most ads pick an orientation and stay with it.
    -Mark

  • StageVideo not visible until orientation change

    Hello,
    I'm trying to show a video on iOS using AIR. I copied to code from some samples I found but I got very wierd results.
    I wrote the code and ran it a few times, the first few times the video worked fine, then when I ran it again, for no aparent reason, I coudln't see the video anymore, but I could still hear it. After many checks I noticed that if I change the device's orientation I can see the video again, even if I return to the original orientation. It's like the video or stage doesn't refresh so the video is not visible and the orientation change somehow causes it to refresh and work again.
    I found that if I change the stage alignment after setting the StageVideo's viewport it works fine again, but this seems like a strange patch..
    Did anyone encounter this behvaiour and knows what causes it and how to fix it?
    Thanks

    I'm seeing the same thing. But it's happening with some video and not with other video.
    See this thread for more details:
    http://forums.adobe.com/message/5755370#5755370

  • Orientation Change?

    I am developing an app for Android and iOS and I want to know how to make the app orientation change with the device orientation from portrait to landscape.
    Is there a way to make the same frame twice for each orientation and have it load the appropriate instance automatically? I would need it to load the 480x800 for portrait and then 800x480 for landscape. I would need it to stay on the correct frame as well. If I am on the contents page, I need it to stay on the contents page and not return to the main menu upon rotation.
    If there is a better way to do this, which I'm sure there is, please let me know! Thanks!

    Here is a simple method just add this to a new layer on frame 1 of the timeline
    Make sure the new layer spans the whole timeline not just 1 frame.
      stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    var isLandscape:Boolean;
    function resizeHandler(e:Event):void
        if ( stage.stageWidth > stage.stageHeight )
            isLandscape = true;
            goToAndStop( 10 ); 
        else
            isLandscape = false;
            goToAndStop( 5 );

  • Orientation changes image

    I am producing an advert for a client that is going to appear in the UK Top Gear magazine.
    Top Gear magazine is landscape only but the gyroscope functions are still available.
    I'm looking to rotate the device 180 degrees and then the background image changes. Does anyone know if tis is possible in DPS or even using Edge Animate content through DPS.
    Ideally I'm looking to produce this without a HTML coder. Thanks.

    Hi, Ellipsis-
    You can do this using some simple code, though if you're not very code savvy, you might need someone to do some JavaScript coding for you.
    Here's a brief post I found on another site that explains the window.orientationChange event, which we support within Animate.
    http://davidwalsh.name/orientation-change
    Please note that given the limitation of this API, you can't necessarily tell whether you've gone 180', but you can definitely tell you if you've gone one way or another.  One other caveat - I'm not 100% sure about this, but your InDesign document may need to support both portrait and landscape mode to be able to make this event fire.
    Hope that helps!
    Cheers,
    -Elaine

  • Device Orientation

    I want to disable the Device Orientation to my application. However when I take off
        // support autoOrients
                 stage.align = StageAlign.TOP_LEFT;
                 stage.scaleMode = StageScaleMode.NO_SCALE;
    It stops the orientation but it doesnt adjust my swf to the correct size of the device.
        public function KD()
                var factory:IGraphicsInterface;
                // support autoOrients
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.addEventListener(Event.RESIZE, resizeHandler);
                stage.dispatchEvent(new Event(Event.RESIZE));

    Found what I was looking for. I open the xml file that the flahs builder AS mobile project creates and add
    <aspectRatio>landscape</aspectRatio>
    and changed  from true to false <autoOrients>false</autoOrients>
    Now I got my landscape view for my application.

  • When orientation change and soft keyboard is activated, return wrong value

    Hello,
    in a View, when the orientation change and the soft keyboard is activated, this.navigator.height return wrong value.
    systemManager.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChangeHandler);
    public function orientationChangeHandler(event:StageOrientationEvent):void {
    inp.text=String(this.navigator.height);
    thanks.

    Can you attach a simple sample application that demonstrates this?  What device are you seeing this issue on?

  • Outbound interface - device modification/reversal & device category change.

    Hi Friends,
    I have a requirement to trigger an outbound interface in the event of device modification/reversal and device category change.I couldn't find any event which gets triggered upon device modification and reversal.There are 2 user exits - call customer '001' and call customer '002' provided by SAP.However,both these exits do not get triggered on device modification.For reversal,there is no exit provided by SAP.I have actually written a code within if....endif..statement in the Zinclude and had put a breakpoint in the Z include of both the device modification exits.None seem to work.
    Similarly there are no events/exits/BAdI's for device category change.I need to trigger the same outbound interface upon device category change.
    This brings me to the conclusion that there is no standard way to do an activity upon completion of device modification/reversal and device category change.There are no BAdI's as well.Change pointer activation could be one of the solution.Could you please suggest an alternative solution.
    Many thanks,
    Raj

    Hi Raj,
    Please check if the default BAdI interface IF_EX_ISU_IDE_DATEXCONNECT is triggered during device modifications / removal.
    Use the method IF_EX_ISU_IDE_DATEXCONNECT~DATEXCONNECT_BILLINGINST_CHNG to see if you can make use of it.
    Thanks,
    Imran

  • I can't open or receive hotmail emails on my macbrook pro, but it works on other devices. i changed my password, emptied the cache, tried using a different browser, etc. i think i have a virus. help!

    I can't open or receive hotmail emails on my macbrook pro, but i can on other devices. i changed my password, emptied the cache, tried using a different browser, etc. i think i have a virus. help!

    Thanks for your help. that's not working either! ugh!!
    I can open hotmail, but it's not formatting right, i can't open emails, nor send them.
    Thank you so much for trying to help. I really appreciate it.
    I understand that you can't get a virus by opening an email, but it seems way too circumstancial! This is my third mac -- because unlike PC -- I never had a problem. I understand this problem is not with my macbook, because every other website works fine -- it's hotmail!

  • Raw device owners change after reboot the server

    The raw device owner change after reboot the server. i have to adjust it manually like
    chown oracle:oinstall /dev/raw/raw*
    any idea to make it permanent after bouncing the Server?
    MY OS is RHEL4 & Rdbms 10.2.0.1

    I got my answer .
    New to Linex. Need suggestions...
    How i can create new file ? like i want to create file oracle.permission
    should i use this command
    touch <filename> or any other command?
    second i want to put these entries raw device 3, 6,7,10,11 etc
    shoud it work ? like in the oracle.permission directory?
    # ASM
    raw/raw[3671011]:oracle:dba:0660

Maybe you are looking for

  • Mac mini 2012 new OWC SSD install issue

    Hoping someone can makes sense of this report. My macmini 2012 has been rock stable. 8 gig, Yosemite install. Yesterday I installed an 120GB Electra 6G SSD as a second drive. Installed a fresh install of Yosemite. Everythign went without a hitch. Sys

  • Why does my Macbook keeps freezing?

    I've had my macbook since thanksgiving 2008 and I have added a few programs to it. Nothing major since I am not a heavy computer user. I've noticed over the past several weeks that I can be in the middle of a webpage or a program and the computer sto

  • Just switched from BTVision to BTYouview

    Ok, all good news so far. Box & activation all spot ontime, and noticed my services are all updated when checking status of latter on My BT page. Install and set-up was trouble free and its good to have the red button and surround sound working again

  • How to terminate an action

    i have a program that does a couple of actions like asks for name, and an array with names. how do you delete any information stored or inputed and have it go back to a fresh new start?

  • Strange problem with KT4V

    I have a strange problem with the board when booting,the cdrw only blinks and can`t read cd`s. I have tried swapping to another cd-rom,but still the same problem.I updated to the new bios (1.9)without problems. my specs are: KT4V 512MB PC2700 MAXTOR