1

I have an application where there are two viewcontrollers say viewcontrollerA and viewcontrollerB.When viewcontrollerA is loaded in portrait mode and I click on the submit button present on the viewcontrollerA viewcontrollerB is presented in portrait mode.this is working fine.When viewcontrollerA is loaded in landscape mode and i click on the submit i want the viewcontrollerB to presented in potrait mode but currently it is displayed in landscape mode.I want to force the viewcontrollerB to be displayed in portrait mode even if it is presented from landscape mode viewcontroller.This is my code:

this is submit code of viewcontrollerA

-(IBAction)submit
{
    LoginNewViewController *lvc  =[[LoginNewViewController alloc] initWithNibName:@"LoginNewViewController" bundle:[NSBundle mainBundle]];
                [self presentModalViewController:lvc animated:YES];

}

this is for viewcontrollerB

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait| UIInterfaceOrientationMaskPortraitUpsideDown);
}
Muddu Patil
  • 713
  • 1
  • 11
  • 24
Rani
  • 3,333
  • 13
  • 48
  • 89
  • I have the similar question here http://stackoverflow.com/questions/15947349/how-to-handle-different-orientations-in-ios-6 – Stas Apr 19 '13 at 08:01

1 Answers1

0

If you want to change the orientation when a particular view is showing, you should call [UIApplication setStatusBarOrientation:animated:] in the button action method.

Balu
  • 8,470
  • 2
  • 24
  • 41
  • have you tried like this [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight]; – Balu Apr 19 '13 at 08:33