ghiboz
ghiboz

Reputation: 8003

Allow only LeftLandscape and RightLandscape orientation

How can I made my app to allow only the landscape orientation but both (left and right)? so if I rotate 180° the app will be rotate but if I rotate in portrait the app doesn't rotate?

thanks

Upvotes: 1

Views: 306

Answers (1)

Jamie Chapman
Jamie Chapman

Reputation: 4239

Try adding this to your UIViewController:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
            interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

You can learn more about this here: UIViewController class reference

Upvotes: 1

Related Questions