Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force TV out of iPad to be in Landscape mode even if iPad is in portrait mode

I am using HDMI cable to take output of my iPad screen to a TV. if i keep the iPad in landscape mode the output on TV shows in landscape mode. and if i rotate it to portrait output on TV changes to portrait mode also.

Is there a way to restrict this i.e. even if i rotate iPad to portrait orientation the output on TV should remain in Landscape

Here are some images which will make clear my question

this is my iPad's orientation...

enter image description here

This is what i am getting.........

enter image description here

This is what i want......

enter image description here OR enter image description here

From messing around with programming i have come this far..

I have made a button over a UIImageView with some image, in a single view application template of Xcode with an IBaction method this method have the following code

- (IBAction)screenButton:(id)sender {
NSLog(@"Screen Count %d",[[UIScreen screens]count]);
if([[UIScreen screens]count] > 1) {

    CGSize max;

    UIScreenMode *maxScreenMode;

    for(int i = 0; i < [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)

    {

        UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];

        if(current.size.width > max.width)

        {
            max = current.size;

            maxScreenMode = current;

        }

    }

    //UIScreen *external = [[UIScreen screens] objectAtIndex:0];

    UIScreen *external = [[UIScreen screens] objectAtIndex:1];

    external.currentMode = maxScreenMode;



    //external_disp = [externalDisplay alloc];

    //external_disp.drawImage = drawViewController.drawImage;

    // ExternalDisplayOn = TRUE;
    //UIImageView *extView = [[UIImageView alloc] init];

     _extView.hidden=FALSE;

    _extView.frame = external.bounds;//MyMainScrollView.frame;

            UIWindow *newwindow = [[UIWindow alloc] initWithFrame:_extView.frame];

    //UIWindow *newwindow = [[UIWindow alloc];

            [newwindow addSubview:_extView];

            newwindow.screen = external;

            newwindow.hidden=NO;


    [[[UIAlertView alloc] initWithTitle:@"Alert Showed" message:[NSString stringWithFormat:@"_extView.frame X %f, Y %f, W %f, H %f, Screen Count %d",_extView.frame.origin.x,_extView.frame.origin.y,_extView.frame.size.width,_extView.frame.size.height,[[UIScreen screens]count]] delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil, nil] show];


            [newwindow makeKeyAndVisible];

    }

}

I was being able to solve my problem by some extent, but the problem i am facing is like the following

whenever i run the app and keep it in portrait mode, the output on TV is the exact replica of my iPad screen .

now when i press the UIButton which i have assigned the code above. a UIAlertView shows up on the iPad screen (but not on the TV screen). and the orientation on TV changes to Landscape with my iPad in Portrait mode(actually this was exactly what i really wanted to do)....

but when i press the cancel button of UIalertView to dismiss the alert view. the orientation on TV output again changes to portrait mode....

is there a way to prevent whats happening in my case, when a UIAlertView shows up. this would solve the issue ..

like image 441
Dev_Dash Avatar asked Feb 26 '14 14:02

Dev_Dash


People also ask

How do I lock my iPad in portrait or landscape mode?

Here's how you can lock your iPad in portrait or landscape mode. This makes it easier for you when you prefer not to have the screen automatically switch to the other orientation while holding your iPad. 1. Double tap the Home button. 2. Scroll all the way to the left on the multitasking bar at the bottom of your iPad's screen. 3.

How to turn on landscape mode on iPad Safari?

Hold the iPad verticle and start Safari, now rotate it left or right 90 degrees. If it doesn't go into landscape mode, check the switch on the side of the iPad above the volume up/down switch. It should be in the up position. If it's down then switch it and try again.

Can I rotate the screen on my iPad?

The screen on your iPad can rotate so that you can see apps like Safari and Messages in portrait or landscape mode. Learn how to rotate the screen on your iPad, or get help if the feature doesn't work.

How to keep iPad screen in preferred orientation?

How to keep your iPad in your preferred orientation 1 Double tap the Home button. 2 Scroll all the way to the left on the multitasking bar at the bottom of your iPad's screen. ... 3 Tap the Lock button to lock the screen after you have it in your preferred orientation.


1 Answers

I don't know whether my idea helps or you already set you program up like this.

In the projekt inspector you can force you iPad to be in a certain orientation. Then your app is only running in this orientation.

Does it helps?

like image 130
Xcoder Avatar answered Oct 21 '22 01:10

Xcoder