0
我正在研究一個項目,我想根據設備的方向替換圖標,但不允許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;
}
有沒有辦法找出哪些輪換我的設備想去,但不允許?所以,我可以改變一個箭頭,文字等...的方向
感謝