title: How to force TV out of iPad to be in Landscape mode even if iPad is in portrait mode
body: <p>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.</p>
  
  <p>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</p>
  
  <p>Here are some images which will make clear my question</p>
  
  <p>this is my iPad's orientation...</p>
  
  <p><img src="https://i.stack.imgur.com/5jeo8.png" alt="enter image description here"></p>
  
  <p>This is what i am getting.........</p>
  
  <p><img src="https://i.stack.imgur.com/QSzzb.png" alt="enter image description here"></p>
  
  <p>This is what i want......</p>
  
  <p><img src="https://i.stack.imgur.com/9MDvs.png" alt="enter image description here">  OR  <img src="https://i.stack.imgur.com/wg3og.png" alt="enter image description here"></p>
  
  <p>From messing around with programming i have come this far..</p>
  
  <p>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</p>
  
  <pre><code>- (IBAction)screenButton:(id)sender {
  NSLog(@"Screen Count %d",[[UIScreen screens]count]);
  if([[UIScreen screens]count] &gt; 1) {
  
      CGSize max;
  
      UIScreenMode *maxScreenMode;
  
      for(int i = 0; i &lt; [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)
  
      {
  
          UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];
  
          if(current.size.width &gt; 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];
  
      }
  
  }
  </code></pre>
  
  <p>I was being able to solve my problem by some extent, but the problem i am facing is like the following</p>
  
  <p>whenever i run the app and keep it in portrait mode, the output on TV is the exact replica of my iPad screen .</p>
  
  <p>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)....</p>
  
  <p>but when i press the cancel button of UIalertView to dismiss the alert view. the orientation on TV output again changes to portrait mode....</p>
  
  <p>is there a way to prevent whats happening in my case, when a UIAlertView shows up. this would solve the issue ..</p>