1

Currently i have this code in all my views which i don't want to go into landscape which is all except for one:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
    return [self.selectedViewController supportedInterfaceOrientations];

return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate
{
return YES;
}

this is the code in my tab bar controller:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
    return [self.selectedViewController supportedInterfaceOrientations];

return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate
{
return YES;
}

And lastly the code in the viewcontroller that i want to go into landscape (because there is a video):

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

- (BOOL)shouldAutorotate
{
return YES;
}

- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}

The views are all rotating like i want them to, the only problem is when the viewcontroller with the video in rotates and you then click on another view that view will stay in landscape, what i want to happen is this view to rotate straight into portrait without the user rotating the device into portrait. Anyone know what code i need?

rexr
  • 89
  • 11

1 Answers1

0

This can be a difficult one to solve elegantly. Forcing orientation can be breaking Human Interface Rules rules or in the past just required calling private API's

I would recommend attempting a different approach which has worked for me in the past. When the user rotates the one viewcontroller that displays a video allow that to rotate but at that time remove any way the user can navigate away and then return those navigation controls when they rotate the device back to portrait. For me it was simply hiding the navigation bar until they returned to portrait. I like this because it is very clear to the user that they have to return the phone to portrait before moving on and they won't be surprised with navigating somewhere else that is magically another orientation.

rooster117
  • 5,502
  • 1
  • 21
  • 19
  • that what involve hiding my tab bar which i dont know how to do, how did you make it impossible to exit the landcape view? – rexr Feb 14 '13 at 10:54
  • It'll be a little work it can be done. http://stackoverflow.com/questions/5272290/how-to-hide-uitabbarcontroller – rooster117 Feb 14 '13 at 14:28