Changing UIDevice Orientation?

Discussion in 'iOS Development' started by Nickll9009, Dec 13, 2008.

  1. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    How do I change the orientation of my app, when the user flips the device?

    So far I have tried:

    Code:
    [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
    And putting this:

    Code:
    <key>UIInterfaceOrientation</key>
    
    <string>UIInterfaceOrientationLandscapeRight</string>
    In my Info.plist

    I get compiler errors though.

    I have also tried:

    Code:
    - (BOOL)shouldAutorotateToInterfaceOrientation:)(UIInterfaceOrientation)interfaceOrientation 
    {
        return YES;
    }
    But again, compiler errors
  2. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    I'm not sure about your application, but i know that with the SDK if your making a UITabBar Application, there are some extra steps you need to take to get it to rotate. Haven't looked at the SDK in a while though, so i couldn't tell you. I found the answer on google i believe. I'll get back to you if i can find it.

    EDIT: http://cocoanotes.wordpress.com/2008/10/29/how-to-rotate-a-uitabbarcontroller/

    Even though i'm not sure if it's a UITabBar application.

    Please Register or Log in to view images

  3. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    It isn't, but thanks anyways

    Please Register or Log in to view images

  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Other than that, then, this has always worked for me:

    Code:
    - (BOOL)shouldAutorotateToInterfaceOrientation:)(UIInterfaceOrientation)interfaceOrientation 
    {
        return YES;
    }
    Are you putting it in the "__ViewController.m"?
  5. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    I'm using the toolchain. When I put that in I get

    "MainApplication.m:50: error: expected identifier before ')' token"
  6. jfb392

    jfb392 New Member

    Joined:
    Oct 20, 2007
    Messages:
    2,512
    Likes Received:
    21
    Device:
    iPod touch
    That's because it's:
    Code:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
    }
    
    You have an extra ).
  7. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    When I use that I get:

    "MainApplication.m:50: error: expected ')' before 'UIInterfaceOrientation'"
  8. godogshomie

    godogshomie New Member

    Joined:
    Nov 19, 2007
    Messages:
    558
    Likes Received:
    3
    Code:
    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    
    if that dont work then u might not have all the correct headers?

Share This Page