I am working on a project where I want to replace the icons based on the orientation of the device without allowing the viewController
to rotate. I have several viewController
that are allowed to rotate and others, specified in my navigation controller that are not allowed to rotate.
This implementation works exactly how i want it to.
Code in my navigation controller:
- (BOOL)shouldAutorotate
{
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[ChimpTabBarController class]]) {
ChimpTabBarController *tabbarController = (ChimpTabBarController*)currentViewController;
if (tabbarController.selectedIndex == 0){
return NO;
}
} else if ([currentViewController isKindOfClass:[RotationViewController class]] || [currentViewController isKindOfClass:[ChimpBlackoutVC class]] || [currentViewController isKindOfClass:[EditPictureVC class]]) {
return NO;
}
return YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
id currentViewController = self.topViewController;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if ([currentViewController isKindOfClass:[ChimpTabBarController class]]) {
ChimpTabBarController *tabbarController = (ChimpTabBarController*)currentViewController;
if (tabbarController.selectedIndex == 0){
return (UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown);
}
} else if ([currentViewController isKindOfClass:[RotationViewController class]] || [currentViewController isKindOfClass:[ChimpBlackoutVC class]] || [currentViewController isKindOfClass:[EditPictureVC class]]) {
return (UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown);
}
return UIInterfaceOrientationMaskAll;
}
Is there any way to find out which rotation my device wants to go to, but is not allowed? So that I can change the direction of an arrow, a word etc...
Thanks