D-32
D-32

Reputation: 3255

shouldAutorotateToInterfaceOrientation return YES

I often see code like this:

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

If the supported orientation is set in the project configuration, wouldn't just returning YES all the time be pointless? Or are there certain cases where this has an effect?

Upvotes: 0

Views: 209

Answers (2)

BoteRock
BoteRock

Reputation: 477

Maybe in many parts of your application you support multiple interface orientations, but in one part you only support some of them (for example you want a video only to play in landscape)

So even if your app supports portrait, you probably want that the viewcontroller makes the orientation landscape

Edit: i'm commenting here because I can't comment other answers.

@daniel-rinser in iOS6, the system checks for project supported interface orientations, and intersects with viewcontroller's supported orientations, so it isn't only for launch but for all app execution.

Upvotes: 1

Daniel Rinser
Daniel Rinser

Reputation: 8855

shouldAutorotateToInterfaceOrientation: (which is deprecated since iOS 6, by the way) is something completely different than the UISupportedInterfaceOrientations in the info plist! If you don't implement this method, the respective view controller won't ever autorotate to that interface orientation, no matter what you specify in UISupportedInterfaceOrientations.

From the documentation of UISupportedInterfaceOrientations:

The system uses this information (along with the current device orientation) to choose the initial orientation in which to launch your app.

Upvotes: 1

Related Questions