Reputation: 7148
Is there to way to fix a view's orientation in a landscape position, regardless of the device's current position?
To be more specific, I have a UIWebView in a UINavigationController that should always show its content as if the device were rotated 90 degress counterclockwise. I only want the web view to be restricted to this orientation; every other view in the app should behave normally.
Upvotes: 0
Views: 643
Reputation: 39376
Yes. In your info.plist file, define:
UIInterfaceOrientation UIInterfaceOrientationLandscapeRight
EDIT:
The above changes the orientation for the whole app, and you say you don't want that. Can the user move the phone to achieve the orientation you need?
If you don't want to rely on the user to change the phone to that orientation, try:
self.view.transform = CGAffineTransformMakeRotation((M_PI * (90) / 180.0));
self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
Upvotes: 2
Reputation: 1386
In the controller for the view, implement shouldAutorotateToInterfaceOrientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
return UIInterfaceOrientationIsLandscape(orientation);
}
Or if you only want to allow Left Landscape (the default for the Youtube app, for example)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
return orientation == UIInterfaceOrientationLandscapeRight;
}
Upvotes: 2