How do you support landscape mode?

Discussion in 'iPhone/iPad Programming' started by JamesFoote, Aug 21, 2008.

  1. macrumors regular

    JamesFoote

    Joined:
    Aug 5, 2008
    #1
    I'm almost done my first app, but I want to be able to know how to support landscape mode.

    (The app displays an RSS feed)
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You need to implement shouldAutorotateToInterfaceOrientation:
     
  3. macrumors 6502a

    TheZimm

    Joined:
    Jul 12, 2008
    #3
    Im a total noob to this stuff, where would you add that
     
  4. macrumors member

    music.addict411

    Joined:
    Jan 8, 2007
    Location:
    Vancouver, Canada
    #4
    yeh

    yeah I second that. All I need to know now is where to add it.
     
  5. thread starter macrumors regular

    JamesFoote

    Joined:
    Aug 5, 2008
    #5
    i

    and I guess I third it.

    Thanks everyone youre all a huge help! :D
     
  6. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Have you tried using the documentation. It's not there for you to ignore whilst you post questions on here.

    I put "shouldAutorotateToInterfaceOrientation" into the search box and the top page returned was titled "Autorotating views". Have you tried, you know, reading it?
     
  7. thread starter macrumors regular

    JamesFoote

    Joined:
    Aug 5, 2008
    #7
    I read the entire guide. It makes next to no sense. I understand that I have to add the code:

    @property(nonatomic, readonly) UIInterfaceOrientation interfaceOrientation

    BUT - I have no idea where I put it in. It says that it needs to be declared in a place that I can't even find!
     
  8. macrumors newbie

    Joined:
    Mar 30, 2008
    Location:
    Brussels, Belgium
    #8
    The method is in your main ViewController. The code for the method is actually already generated for you when you generate a new project with view.

    Replace:

    - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
    {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }

    with:

    - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
    {
    return YES;
    }

    For more info:
    http://developer.apple.com/iphone/l...S/AutorotatingViews/chapter_11_section_1.html
     
  9. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    You should probably take the time to learn the language then, rather than just trying to copy and paste code. I don't mean to sound harsh, but if you need someone to tell you where to place some code then you don't know the language and ultimately you'll produce poor software.

    I'm not even attempting to write an iPhone application until I feel like I have a good strong grasp of Objective-C and the Cocoa APIs and I have the advantage of knowing C already.
     
  10. macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #10
    In Mac programming, something of that nature would commonly be found in the header file ;).
     

Share This Page