I have a UIViewController
detail view which is pushed from a UITableView
in a UINavigationController
. In the UIViewController
I add a number of subviews (e.g a UITextView
, UIImageView
).
In iOS5
I used this code to stop autorotation if my picture view was enlarged :
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (scrollView.isZoomed) {
return NO;
}
else {
return YES;
}
}
I am trying to achieve the same thing under iOS6
using :
- (BOOL)shouldAutorotate {
return FALSE;
}
However this method is never called and the app continues rotating.
Can anyone help ?
If you have a Navigation Controller managing these views, the shouldAutorotate method won't be called. You would have to subclass UINavigationController and override methods shouldAutorotate and supportedIntervalOrientations.
From the docs:
Edit-----
As mentioned below by Lomax, subclassing UINavigationController is discouraged by Apple. You should try a category instead (this SO question explains it well):