I saw this in another post. I get that I need to override the first method for iOS5 and the following two for iOS6.
iOS 5:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
iOS 6
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight;
}
But, I do have some questions with how to use them properly.
- Let's say i set the supportedOrientations in the settings of my XCode project, do I have to implement shouldAutoRotate and SupportedInterfaceOrientations? What happens if I don't?
- If I don't override shouldAutoRotate, is the default value YES?
- If I return NO in shouldAutorotateToInterface, i get a warning "shouldAutorotateToInterfaceOrientation: for all interface orientations. It should support at least one orientation." Is this bad? Does it have an implication in my app?
- When do you get the crash "Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES;"
- What will happen if I return NO in shouldAutorotate and I have multiple supprotedInterfaceOrientations? Is it the same as just using portrait because my VC won't be rotation?
- What if I return YES in shouldAutorotate, I have multiple supported orientation in my Xcode settings but I override a supportedInterfaceOrientations and return only 1?