4 개의 탭 표시 줄 항목이있는 uitabbarcontroller가 있고 각 탭 표시 줄 항목에 uinavigationcontroller가 있습니다.하나의 UITabbar 항목에 대해 순환 사용 안 함
하나의 uitabbar 항목의 방향을 Portrait에만 고정해야했습니다. 그래서 나는 다음과 같은 코드를 구현 :
만든 사용자 지정 탭 표시 줄 컨트롤러를과에 다음 코드를 추가 :
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
return [self.selectedViewController supportedInterfaceOrientations];
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate
{
return YES;
}
이 중 하나를 사용하여 사용자 정의 탐색 컨트롤러를 생성
MainTabBarController.m을 uitabbaritems와는 다음 코드 추가 :
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
-(BOOL)shouldAutorotate
{
return YES;
}
를 상기 지정 탐색 제어기에 UIViewController에 대한 난 FO 추가 코드 작성 중 :
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
위의 코드는 정상적으로 작동합니다. 내 문제는 장치가 이미 가로 모드에있을 때 방향이 Protrait로 잠긴 탭 모음 항목으로 이동하면 방향이 가로로 변경된다는 것입니다. 아무도 내 문제를 해결하는 방법을 도와주세요.
감사합니다. Anand.
세로에서 가로로 변경할 때 작은 애니메이션이 나타납니다. 이 애니메이션을 NO로 설정하는 방법이 있습니까? –
@justME 죄송합니다. 해당 애니메이션을 NO로 설정하는 방법을 모르겠습니다. 알아 내면 알려주세요. –
코드를 업데이트했습니다. –