私は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;
}
は私のデバイスがに行きたいが、許可されていない回転かを調べる方法はありますか?ように私は...私はむしろ予想よりも早く、道自分自身を発見した
おかげ