UIOrientableApplication Code

Discussion in 'iOS Development' started by jYopp, Feb 5, 2008.

  1. jYopp

    jYopp New Member

    Joined:
    Jan 29, 2008
    Messages:
    5
    Likes Received:
    0
    I searched far and wide for a good how-to on doing apps that can change their orientation, and found that not only was there no how-to, virtually nobody had implemented this feature! iphonecomic supports screen rotation, but the source comments are in Japanese, limiting accessibility, and only the image view is rotated -- in a way that leaves artifacts and reduces quality from scaling (at least, when I do things the same way).

    So, after messing around with a whole boatload of quirky parameters and a member function in UIWindow (setRotationDegrees: duration

    Please Register or Log in to view images

    that never seemed to work quite right, I present UIOrientableApplication. This is a subclass of UIApplication that is intended for use with Auto-Resizable controls. I'm distributing it as part of a complete demo application.

    This has been compiled and tested against firmware 1.1.1. If anyone finds this useful, by all means include it in your own applications. I want to see more third-party apps taking advantage of rotation!

    If you don't want to use gravity-controlled auto-orientation, the class includes a method titled "lockUIToOrientation" that allows you to manually spin things around with animations.

    One thing that's not in the demo: Use [app setAngleForOrientation

    Please Register or Log in to view images

    toDegrees:d] to define the display angle for a particular hardware orientation code. Currently, it's configured to support the three-orientation setup by default, like Safari -- one portrait and both landscape layouts. This will allow you to support upside-down portrait view, and/or explicitly define a layout for otherwise uninteresting states (face-up and face-down).

    Attached Files:

  2. jpmassena

    jpmassena New Member

    Joined:
    Nov 25, 2007
    Messages:
    4
    Likes Received:
    0
    hi! don't know if you want this info, but while i was trying this app, the text on the middle said "if you find something that gives you this value, let me know!". The ipod was on the table without nobody touching it...

    btw, good work on this
  3. jYopp

    jYopp New Member

    Joined:
    Jan 29, 2008
    Messages:
    5
    Likes Received:
    0
    >> "If you find something that gives you this value..."

    AHA! Good clue. It seems that I can now semi-reliably get an orientation code of 5 when I am in the process of picking the iPod up or putting it down onto the table. Once the movement stops, it goes straight back to the expected reading.

Share This Page