Antonio
Antonio

Reputation: 535

iPad Landscape only (left or right)

I am building an app and I would like it to be landscape only, even if rotated. After reading around, I have set up aline of code like this:

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

This works, but I would like the interface to rotate but always in landscape mode only, with left or right home button, like many other apps do...

How to get this?

Upvotes: 0

Views: 2769

Answers (3)

Aragon
Aragon

Reputation: 61

A useful link to describe how to build a landscape only app in iPhone, but it also works in iPad. http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html

Upvotes: 0

James J
James J

Reputation: 6458

Try this:

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

Upvotes: 3

bosmacs
bosmacs

Reputation: 7483

You're very close, just need to support all landscape orientations, most easily done using the UIInterfaceOrientationIsLandscape macro.

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

Upvotes: 1

Related Questions