Я работаю над проектом, где я хочу заменить значки на основе ориентации устройства, не позволяя вращаться viewController
. У меня есть несколько viewController
, которым разрешено вращать и другие, указанные в моем контроллере навигации, которым не разрешено вращаться.Как определить ориентацию устройства, когда shouldAutorotate = NO и разрешен только портрет?
Эта реализация работает именно так, как я ее хочу.
код в моей навигации контроллера:
- (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;
}
Есть ли способ, чтобы выяснить, какие вращение мое устройство хочет идти, но не допускается? Так что я могу изменить направление стрелки, слова и т.д. ...
Благодаря