Reputation: 2318
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.
Upvotes: 1
Views: 1231
Reputation: 1792
I'm doing the vast majority of these answer by memory so there might be some errors...
Yes. Tested it in a new project with:
// Should autorotate not implemented
-(void)viewDidLoad {
[super viewDidLoad];
NSLog(@"%@", [self shouldAutorotate]?@"y":@"n");
}
shouldAutorotateToInterfaceOrientation:
. Either support orientations and give the possible ones or don't.That said, it's usually very difficult to get the exact desired behavior. So the usual approach is 'trial & error'. Or as one of my teachers always said 'error & trial' because you are already making an error with that approach =)
Upvotes: 2