iPhone orientation

Discussion in 'iPhone/iPad Programming' started by mbpc2d.user, Apr 6, 2008.

  1. macrumors newbie

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

    #2
    You can not set the default orientation.
     
  3. macrumors newbie

    #3
    hmm, that presents a problem lol. thanks dude
     
  4. macrumors member

    #4
    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. macrumors newbie

    #5
    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

    #6
    well..In fact you can set the "default" orientation

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

    Check it out:

    http://developer.apple.com/iphone/l...ENERAL-START_MY_APPLICATION_IN_LANDSCAPE_MODE

    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

    #7
    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.

    Regards,
    GC
     
  8. macrumors newbie

    #8
    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,
    Deepak
    www.umundo.com
     

    Attached Files:

  9. macrumors newbie

    #9
    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!

    Nelson
     
  10. macrumors newbie

    #10
    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..



    Thanks,
    Deepak
    www.umundo.com
     
  11. macrumors 68030

    PhoneyDeveloper

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

    #12
    Problem is same

    Hi,
    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..


    Thanks
     
  13. macrumors 68030

    PhoneyDeveloper

    #13
    What about the autoresizingMask for the imageView?
     
  14. macrumors newbie

    #14
    Orientation problem

    Hello,
    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.




    Ashli
     
  15. macrumors newbie

    #15
    hello!

    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

    nickculbertson

    #16
    try

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

Share This Page