내 응용 프로그램은 세로 전용으로 구성되어 있습니다. 거기 두 내가 자동 회전 할 전망. 따라서 응용 프로그램 대리자에서 다음 함수를 재정의했습니다.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskAll;
}
내 모든 뷰는 다음 기능을 재정의 한 하나의 뷰를 상속합니다.
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
이를 통해 모든 뷰를 세로 방향으로 유지할 수 있습니다.
자동 회전하려는 두 가지보기에서 다음 방법을 재정의했습니다.
- (BOOL)shouldAutorotate
{
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown | UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}
그리고 이것은 또한 esxpected로 작동합니다.
그러나 모달로 표시되는 뷰는 장치 방향으로 열려 있습니다. 장치를 가로 방향으로 회전하고 모달로 뷰를 열면 기본 뷰를 상속하고 이러한 메서드를 재정의하지 않더라도 가로 레이아웃을 가져옵니다.
이에 대한 이유와 해결책을 찾았습니다.
내 뷰는 UINavigationController에 의해 관리되고 있으므로 하위 클래스를 만들고 위에서 언급 한 모든 기능을 똑같은 방식으로 재정의해야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다