1
votes

I have an application that needs to run in both portrait and Landscape mode in iPhone.

Everything works fine on all the modes. What happens is if user turns the phone to the LandscapeLeft mode the view is displayed in Landscape left and if user turns the device to LandscapeRight the view is rotated to Landscape Right.

And What I want is to trigger LandscapeLeft view on both the orientation LandscapeLeft and LandscapeRight of the device.

Is it possible technically? I guess NO. So is there any way to achieve this?

EDIT: To make the concept more clear I add an example image. The finger in the image must always point to the Home button of the iPhone device no matter where it is rotated (upside down is not supported) Portrait view

Landscape View

3
So if the user is holding the device in Landscape Right then what? Do you want the display to be upside-down?Fogmeister
Portrait is just fine.. On Landscape right too I want to display Landscape leftSuresh Varma
I don't understand what you mean "On landscape right I want it to display landscape left". What does that mean? Landscape Left and Landscape Right are named that because of the way the device is rotated. It seems arbitrary to allow landscape right but not left. Why is it that you don't want landscape left?Fogmeister
From your comments on the answers. "I want it to show landscape right when held landscape left". Can I ask what you think this means? I don't think it means what you think it means.Fogmeister
Maybe some pictures would help here. Clearly we are not getting the message.Fogmeister

3 Answers

1
votes

OK, so to get this to work you will need to enable all the orientations you want to work.

So, enable Left, Right and Portrait.

Then you have one image...

enter image description here

Now you need the function that is called when the device orientation is change...

// pseudo code...
- (void)orientationChanged
{
    CGAffineTransform transform;

    switch (currentOrientation) {
        case portrait:
            // rotate from pointing right to pointing down
            transform = CGAffineTransformMakeRotation(M_PI / 2);
            break;
        case left:
            // flip horizontally
            transform = CGAffineTransformMakeScale(-1, 1);
            break;
        case right:
            // pointing right
            transform = CGAffineTransformIdentity;
            break;
    }

    self.pointingImageView.transform = transform;
}

Or something like this anyway.

By using rotation and scaling you can make the same image point in all directions. But you have to actually do it yourself. You can't just rely on the orientation change to do it.

If you want to use different images for each direction then just swap out the transform stuff for changing images. The concept remains the same though.

0
votes

This is a more generalist answer (applicable to SVG, native apps or whatever) just to help people visualize the problem. (In my experience, once you know how to define the issues, you can find ways to solve them for any platform or programming language)

diagram showing image conditions

I believe Fogmeister has a workable solution for this question. But just remember, flip the content on both X and Y axes and you'll achieve what you want.

-1
votes

You can select device orientation options as portrait , portrait upside down,Landscape Right in deployment info