Reputation: 33644
I have the following code in my UIViewController and I am testing for iOS 5 in a device and both simultor.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (IS_IPHONE){
return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
} else {
return YES;
}
}
I put a breakpoint and it is indeed getting called, however it still rotates to landscape. Why is this?
Upvotes: 0
Views: 91
Reputation:
Because you told it to do so. return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
means that you want to autorotate to every direction except portrait upside-down, and that includes landscape. For iPad, even this constraint is missing, so it will autrotate to any orientation.
(You should have a fresh breath of documentation...)
Upvotes: 2
Reputation: 3054
Use this instead
return (interfaceOrientation == UIInterfaceOrientationPortrait);
Upvotes: 1