For my app rootViewController
is navgationController
.
I found that pushed controller\'s
-(BOOL)shouldAutorotate
is not
I also faced the same issue with the navigation controller. It works fine in the case of all the pushed view controllers, but my scenario was quite different I had one viewcontroller pushed in to the navigation controller (ViewControllerParent) as the root,
NavController
-- rootViewController (ViewControllerParent)
--- ViewControllerChild1
--- ViewControllerChild2
Due to some project requirement, I was keeping the ViewControllerParent as base, and then I was adding Child viewcontroller's view as subviews to the parent based on user actions. Now I had a scenario where I wanted Child1 not to rotate and Child2 to have rotation.
The problem I faced was that my [self.topViewController] in the Navigation controller class always returns me the Parent Object since I am not pushing the Childs into the nav stack. So my shouldAutorotate methods in my Childs will never be called. So I had to put a class check in the shouldAutorotate method of my parent and then return the rotation value. I did something like this in parent class (ViewControllerParent),it is a kind of workaround but it fixed the issue
-(BOOL)shouldAutorotate
{
BOOL allowRotation = YES;
if ([currentlyLoadedChild isKindOfClass:[Child1 class]])
{
allowRotation = NO;
}
if ([currentlyLoadedChild isKindOfClass:[Child2 class]])
{
allowRotation = YES;
}
return allowRotation;
}
-anoop