iPhone orientation

Discussion in 'iOS Programming' started by mbpc2d.user, Apr 6, 2008.

  1. macrumors newbie

    Apr 4, 2008
    I have it so I can rotate my program, but how can I set the default orientation?
  2. macrumors member

    Oct 26, 2007
    [[NSLocation alloc] initWithCity: Chicago]
    You can not set the default orientation.
  3. thread starter macrumors newbie

    Apr 4, 2008
    hmm, that presents a problem lol. thanks dude
  4. macrumors member

    Oct 26, 2007
    [[NSLocation alloc] initWithCity: Chicago]
    You could however get the current orientation and if it is not the way you like it alert the user to roatet the device.. But your UI should just make them realize that they need the device rotated such as the Kalimba sample.
  5. thread starter macrumors newbie

    Apr 4, 2008
    yeah, I thought about that. the kimbala and bubblelevel apps both maintain there portrait orientations and since nothing moves or rotates, it works. but i was hoping to be able to allow my app run in landscape mode and allow the user to choose landscapeleft or lanscaperight. but i guess i could just keep it portrait and force the user to hold it one way, and since thats how apples examples are, they shouldn't have a problem with that style.
  6. macrumors newbie

    Jul 25, 2008
    well..In fact you can set the "default" orientation

    well..in fact you can set the "default" orientation for the application...

    Check it out:


    You need to edit your Info.plist file to add the UIInterfaceOrientation key with the appropriate value (UIInterfaceOrientationLandscapeRight or UIInterfaceOrientationLandscapeLeft).

    but I guess what you are asking is how to have a view to be "landscape" when your application is set to portrait mode view? well...I'm trying to do the same thing...the youtube application behaves this way which is kinda curious.

    If someone comes up with something please post!! :rolleyes:
  7. macrumors newbie

    Sep 3, 2008
    UIDevice setOrientation

    Actually you can change it with this statement

    [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];

    The UIDevice's orientation property is read-only and the compilator marks a warning... but works fine ^_^.
    Maybe there's a better way to do it, but I couldn't find another solution.

  8. macrumors newbie

    Jun 26, 2008
    Problem in orientation

    Hi all,

    I am implementing orientation in my application view. But when my device rotate to left or right with that my image is also rotates but that time a blank black view is display in 1/4 part of the screen, i don't know why.
    I am just doing
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    return YES;

    I am attaching the screen which i am getting after rotation, in that the corner black frame is displaying after rotation, and i don't know why ? and that frame cut my half image.

    Please help me how can i solve this problem.

    Thanks in Advance,

    Attached Files:

  9. macrumors newbie

    Jul 25, 2008
    deepak, try resizing your image_view to fit the landscape mode. The OS merely handles the rotation but does not resize your screen or places your UI controls in the correct place, you need to handle that manually.
    hope it helps!

  10. macrumors newbie

    Jun 26, 2008
    Problem in Orientation and Zooming

    Acutely i used UIScrollView and added the image in that like [scrollView addSubview:imageView]; it works fine, but i used zooming and orientation both.. my orientation code is working fine with the help of your reply. But when i done zoom with scale 3-4 and if then used left or right orientation then my image get out from my scrollview.

    I don't know why..

  11. macrumors 68030


    Sep 2, 2008
    @deepak, You need to set the autoresizeMask for your views so they're resized when the device rotates.
  12. macrumors newbie

    Jun 26, 2008
    Problem is same

    I used all that in my code like
    scrollView.autoresizingMask =
    ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    scrollView.maximumZoomScale = 5;
    scrollView.minimumZoomScale = 1;
    scrollView.clipsToBounds = YES;
    scrollView.autoresizesSubviews = YES;

    But problem is same..

  13. macrumors 68030


    Sep 2, 2008
    What about the autoresizingMask for the imageView?
  14. macrumors newbie

    Feb 2, 2009
    Orientation problem

    In my iPhone application i used zooming and orientation both. But at the time of orientation i am giving back button only when in UIDeviceOrientationPortrait mode, not with other mode.
    My application get failed because of above region.

  15. macrumors newbie

    Dec 17, 2010

    I have an application with three views, the first two buttons to go in the other two. I would like one of the views will be displayed in landscape.

    I tried [[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight], but it not work.

    I set its direction in interface builder but he is still in portrait.

    If you have an idea, I know because I am confused here.
  16. macrumors regular


    Nov 19, 2010
    Nashville, TN

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);

Share This Page