Reputation: 1779
Is there a way to force ipads and iphones to render the web based layout in landscape mode only?
Upvotes: 0
Views: 870
Reputation: 3833
You can't force Safari to stay in a specific orientation, but you can detect it.
body[orient="landscape"]
or body[orient="portrait"]
can be used in your CSS to render two different layouts. If you choose, one of them (portrait in this case) can display a "not optimized for this layout" screen of some sort.
I suppose you could try to do a -webkit-transform: rotate(-90deg)
on the body of the page, but if the page scrolls that probably would not be feasible. If your layout was exactly the right size, though, it might look pretty close to correct.
Upvotes: 1
Reputation: 478
You have to prevent the view from rotating with:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return NO;
}
then you have to initiate the view in landscape this way you will prevent the view from rotating.
Upvotes: 1