How to make the TV from the iPad be in landscape mode, even if the iPad is in portrait mode

I use an HDMI cable to display my iPad screen on a TV. if I save the iPad in landscape mode, the output on the TV screen in landscape mode. and if I turn it to portrait output on the TV, then to portrait mode.

Is there a way to limit this, even if I rotate the iPad to portrait orientation, the TV output should remain in Landscape

Here are some images that will clearly state my question

this is my orientation on the iPad ...

enter image description here

This is what I get .........

enter image description here

This is what I want ......

enter image description here OR enter image description here

I went so far from messing with programming.

I made a button over a UIImageView with some image, in one application template of the Xcode view with the IBaction method, this method has 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]; } } 

To some extent, I could solve my problem, but the problem I encountered is as follows

whenever I launch the application and save it in portrait mode, the output to the TV is an exact copy of my iPad screen.

now when i click the UIButton to which i have assigned the code above. UIAlertView is displayed on the iPad screen (but not on the TV screen). and the orientation on the TV screen changes to "Landscape" with my iPad in the "Portrait" mode (in fact, this is exactly what I really wanted) ....

but when I click the UIalertView cancel button to close the warning window. the orientation at the TV output changes to portrait mode again ....

Is there a way to prevent what happens in my case when a UIAlertView appears. this would solve the problem.

+8
ios objective-c ipad uiscreen uialertview
source share
4 answers

I don’t know if my idea helps, or have you configured the program this way.

In the project inspector, you can make you iPad be in a specific orientation. Then your application only works in this orientation.

Does it help?

+1
source share

You must make a separate UIViewController for newwindow.rootViewController where you can define the appropriate supported orientations - https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/ occ / instm / UIViewController / supportedInterfaceOrientations

+1
source share

You can try to set the 90-degree transform in the view and change it to the borders of the screen, but with the replacement of the size components.

Something like:

 CGRect screenBounds = external.bounds; _extView.transform = CGAffineTransformMakeRotation((CGFloat)M_PI_2); _extView.bounds = CGRectMake(0,0,screenBounds.size.height, screenBounds.size.width); 
+1
source share

You can customize the orientation of your applications as you like using the application delegate.

 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { NSLog(@"Interface orientation Portrait = %@",enablePortrait); if(wantAppliactionTobeLandscape) return UIInterfaceOrientationMaskLandscapeRight; else return UIInterfaceOrientationMaskPortrait; } 

make the bool appropriately and set it as required.

+1
source share

All Articles